Get problem with Windows Form Designer generated code

smiles

Well-known member
Joined
May 21, 2008
Messages
47
Programming Experience
Beginner
I use the code about video capture of this site, it ran very well !
VB Helper: HowTo: Capture video from a video device such as a Webcam with VB .NET

But I want to change the interface of form then after I customize my new one with button, picturebox ... (with the right name), copy the code again except this paragraph
VB.NET:
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents picCapture As System.Windows.Forms.PictureBox
    Friend WithEvents lstDevices As System.Windows.Forms.ListBox
    Friend WithEvents lblDevice As System.Windows.Forms.Label
    Friend WithEvents btnStart As System.Windows.Forms.Button
    Friend WithEvents btnSave As System.Windows.Forms.Button
    Friend WithEvents btnStop As System.Windows.Forms.Button
    Friend WithEvents sfdImage As System.Windows.Forms.SaveFileDialog
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.picCapture = New System.Windows.Forms.PictureBox()
        Me.lstDevices = New System.Windows.Forms.ListBox()
        Me.lblDevice = New System.Windows.Forms.Label()
        Me.btnStart = New System.Windows.Forms.Button()
        Me.btnSave = New System.Windows.Forms.Button()
        Me.btnStop = New System.Windows.Forms.Button()
        Me.sfdImage = New System.Windows.Forms.SaveFileDialog()
        Me.SuspendLayout()
        '
        'picCapture
        '
        Me.picCapture.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.picCapture.Location = New System.Drawing.Point(208, 24)
        Me.picCapture.Name = "picCapture"
        Me.picCapture.Size = New System.Drawing.Size(256, 272)
        Me.picCapture.TabIndex = 0
        Me.picCapture.TabStop = False
        '
        'lstDevices
        '
        Me.lstDevices.Location = New System.Drawing.Point(8, 55)
        Me.lstDevices.Name = "lstDevices"
        Me.lstDevices.Size = New System.Drawing.Size(184, 238)
        Me.lstDevices.TabIndex = 1
        '
        'lblDevice
        '
        Me.lblDevice.Location = New System.Drawing.Point(8, 32)
        Me.lblDevice.Name = "lblDevice"
        Me.lblDevice.Size = New System.Drawing.Size(184, 16)
        Me.lblDevice.TabIndex = 2
        Me.lblDevice.Text = "Available Devices"
        Me.lblDevice.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'btnStart
        '
        Me.btnStart.Location = New System.Drawing.Point(20, 320)
        Me.btnStart.Name = "btnStart"
        Me.btnStart.Size = New System.Drawing.Size(112, 32)
        Me.btnStart.TabIndex = 3
        Me.btnStart.Text = "Start Preview"
        '
        'btnSave
        '
        Me.btnSave.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)
        Me.btnSave.Location = New System.Drawing.Point(348, 320)
        Me.btnSave.Name = "btnSave"
        Me.btnSave.Size = New System.Drawing.Size(112, 32)
        Me.btnSave.TabIndex = 4
        Me.btnSave.Text = "Save Image"
        '
        'btnStop
        '
        Me.btnStop.Location = New System.Drawing.Point(184, 320)
        Me.btnStop.Name = "btnStop"
        Me.btnStop.Size = New System.Drawing.Size(112, 32)
        Me.btnStop.TabIndex = 5
        Me.btnStop.Text = "Stop Preview"
        '
        'sfdImage
        '
        Me.sfdImage.FileName = "Webcam1"
        Me.sfdImage.Filter = "Bitmap|*.bmp"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(480, 382)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnStop, Me.btnSave, Me.btnStart, Me.lblDevice, Me.lstDevices, Me.picCapture})
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Video Capture"
        Me.ResumeLayout(False)

    End Sub

#End Region
Now it buid no error but doesn't run anymore :confused:
Maybe some basic things that I don't understand, could you tell me why ?
Thanks !!!
 
Not sure I follow you, are you saying you edited the generated code and now have problems? Or did you change the form controls and not wire up the code properly to your video capture?
 
Well I change how the form looks like, color, background, ... use the same controls with the same name and all code attached to it, except the " Windows Form Designer generated code " as you see above :confused:
Try Option Strict On, but not work :(
 

Attachments

  • VideoCapture.zip
    16 KB · Views: 30
Last edited by a moderator:
Every Event-Handler is missing in the main Code of Form1. Re-Add them.

VB.NET:
Private Sub btn_save_Click(Byval sender As Object, Byval e As EventArg) [b]Handles btn_save.Click()[/b]

Bobby
 

Latest posts

Back
Top