AddCam.vb
Upload User: wuming6209
Upload Date: 2013-06-06
Package Size: 161k
Code Size: 5k
Category:

Video Capture

Development Platform:

Visual C++

  1. Imports DirectX.Capture
  2. Public Class AddCam
  3.     Inherits System.Windows.Forms.Form
  4. #Region " C骴igo generado por el Dise馻dor de Windows Forms "
  5.     Public Sub New()
  6.         MyBase.New()
  7.         'El Dise馻dor de Windows Forms requiere esta llamada.
  8.         InitializeComponent()
  9.         'Agregar cualquier inicializaci髇 despu閟 de la llamada a InitializeComponent()
  10.         Dim j As Short
  11.         Dim f As Filter
  12.         'Add to cboCamaras available cameras
  13.         cboCamaras.Items.Clear()
  14.         For j = 0 To Dispositivos.VideoInputDevices.Count - 1
  15.             f = Dispositivos.VideoInputDevices(j)
  16.             cboCamaras.Items.Add(f.Name)
  17.         Next
  18.     End Sub
  19.     'Form reemplaza a Dispose para limpiar la lista de componentes.
  20.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  21.         If disposing Then
  22.             If Not (components Is Nothing) Then
  23.                 components.Dispose()
  24.             End If
  25.         End If
  26.         MyBase.Dispose(disposing)
  27.     End Sub
  28.     'Requerido por el Dise馻dor de Windows Forms
  29.     Private components As System.ComponentModel.IContainer
  30.     'NOTA: el Dise馻dor de Windows Forms requiere el siguiente procedimiento
  31.     'Puede modificarse utilizando el Dise馻dor de Windows Forms. 
  32.     'No lo modifique con el editor de c骴igo.
  33.     Friend WithEvents cboCamaras As System.Windows.Forms.ComboBox
  34.     Public WithEvents cmdCancel As System.Windows.Forms.Button
  35.     Public WithEvents cmdOK As System.Windows.Forms.Button
  36.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  37.         Me.cboCamaras = New System.Windows.Forms.ComboBox()
  38.         Me.cmdCancel = New System.Windows.Forms.Button()
  39.         Me.cmdOK = New System.Windows.Forms.Button()
  40.         Me.SuspendLayout()
  41.         '
  42.         'cboCamaras
  43.         '
  44.         Me.cboCamaras.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)
  45.         Me.cboCamaras.Location = New System.Drawing.Point(40, 16)
  46.         Me.cboCamaras.Name = "cboCamaras"
  47.         Me.cboCamaras.Size = New System.Drawing.Size(184, 21)
  48.         Me.cboCamaras.TabIndex = 4
  49.         Me.cboCamaras.Text = "Click to chose a camera"
  50.         '
  51.         'cmdCancel
  52.         '
  53.         Me.cmdCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)
  54.         Me.cmdCancel.BackColor = System.Drawing.SystemColors.Control
  55.         Me.cmdCancel.Cursor = System.Windows.Forms.Cursors.Default
  56.         Me.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
  57.         Me.cmdCancel.ForeColor = System.Drawing.SystemColors.ControlText
  58.         Me.cmdCancel.Location = New System.Drawing.Point(168, 56)
  59.         Me.cmdCancel.Name = "cmdCancel"
  60.         Me.cmdCancel.RightToLeft = System.Windows.Forms.RightToLeft.No
  61.         Me.cmdCancel.Size = New System.Drawing.Size(81, 25)
  62.         Me.cmdCancel.TabIndex = 5
  63.         Me.cmdCancel.Text = "Cancel"
  64.         '
  65.         'cmdOK
  66.         '
  67.         Me.cmdOK.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)
  68.         Me.cmdOK.BackColor = System.Drawing.SystemColors.Control
  69.         Me.cmdOK.Cursor = System.Windows.Forms.Cursors.Default
  70.         Me.cmdOK.ForeColor = System.Drawing.SystemColors.ControlText
  71.         Me.cmdOK.Location = New System.Drawing.Point(72, 56)
  72.         Me.cmdOK.Name = "cmdOK"
  73.         Me.cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No
  74.         Me.cmdOK.Size = New System.Drawing.Size(81, 25)
  75.         Me.cmdOK.TabIndex = 3
  76.         Me.cmdOK.Text = "OK"
  77.         '
  78.         'AddCam
  79.         '
  80.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  81.         Me.ClientSize = New System.Drawing.Size(264, 93)
  82.         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cboCamaras, Me.cmdCancel, Me.cmdOK})
  83.         Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
  84.         Me.MaximizeBox = False
  85.         Me.MinimizeBox = False
  86.         Me.Name = "AddCam"
  87.         Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  88.         Me.Text = "AddCam"
  89.         Me.ResumeLayout(False)
  90.     End Sub
  91. #End Region
  92.     Private Sub cmdOK_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdOK.Click
  93.         Dim IdVentana As String
  94.         If cboCamaras.SelectedItem = Nothing Then
  95.             MsgBox("Select an available camera.", MsgBoxStyle.Exclamation, "Error")
  96.             Exit Sub
  97.         End If
  98.         CaptureInformation.Camera = Dispositivos.VideoInputDevices(cboCamaras.SelectedIndex)
  99.         CaptureInformation.CaptureInfo = New Capture(CaptureInformation.Camera, Nothing)
  100.         Me.Dispose()
  101.     End Sub
  102.     Private Sub cmdCancel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCancel.Click
  103.         Me.Dispose()
  104.     End Sub
  105. End Class