home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / MainForm.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-06-26  |  16.3 KB  |  487 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Object = "{00100023-B1BA-11CE-ABC6-F5B2E79D9E3F}#1.0#0"; "LTCAP10N.OCX"
  4. Begin VB.Form MainForm 
  5.    BorderStyle     =   3  'Fixed Dialog
  6.    Caption         =   "LEADTOOLS VB Capture Demo"
  7.    ClientHeight    =   3870
  8.    ClientLeft      =   555
  9.    ClientTop       =   1725
  10.    ClientWidth     =   6210
  11.    Icon            =   "MainForm.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    PaletteMode     =   1  'UseZOrder
  16.    ScaleHeight     =   3870
  17.    ScaleWidth      =   6210
  18.    ShowInTaskbar   =   0   'False
  19.    Begin LEADCapLibCtl.LEADCap LEADCap1 
  20.       Height          =   375
  21.       Left            =   3360
  22.       OleObjectBlob   =   "MainForm.frx":030A
  23.       TabIndex        =   25
  24.       Top             =   2400
  25.       Width           =   495
  26.    End
  27.    Begin VB.CommandButton Command4 
  28.       Caption         =   "About..."
  29.       Height          =   420
  30.       Left            =   4440
  31.       TabIndex        =   27
  32.       Top             =   3015
  33.       Width           =   855
  34.    End
  35.    Begin VB.CommandButton Command3 
  36.       Caption         =   "Save As..."
  37.       Height          =   420
  38.       Left            =   3120
  39.       TabIndex        =   26
  40.       Top             =   3015
  41.       Width           =   990
  42.    End
  43.    Begin VB.CommandButton Command2 
  44.       Caption         =   "Capture Info"
  45.       Height          =   420
  46.       Left            =   2040
  47.       TabIndex        =   24
  48.       Top             =   3015
  49.       Width           =   990
  50.    End
  51.    Begin VB.TextBox Status 
  52.       BackColor       =   &H80000004&
  53.       Enabled         =   0   'False
  54.       BeginProperty Font 
  55.          Name            =   "MS Sans Serif"
  56.          Size            =   8.25
  57.          Charset         =   0
  58.          Weight          =   700
  59.          Underline       =   0   'False
  60.          Italic          =   0   'False
  61.          Strikethrough   =   0   'False
  62.       EndProperty
  63.       Height          =   300
  64.       Left            =   0
  65.       TabIndex        =   20
  66.       Top             =   3510
  67.       Width           =   6210
  68.    End
  69.    Begin VB.CommandButton CloseBtn 
  70.       Caption         =   "Close"
  71.       Height          =   420
  72.       Left            =   5400
  73.       TabIndex        =   19
  74.       Top             =   3015
  75.       Width           =   750
  76.    End
  77.    Begin VB.Frame Frame2 
  78.       Caption         =   "Capture Options"
  79.       Height          =   2715
  80.       Left            =   3480
  81.       TabIndex        =   13
  82.       Top             =   180
  83.       Width           =   2625
  84.       Begin VB.ComboBox AudioFormat 
  85.          Height          =   315
  86.          ItemData        =   "MainForm.frx":0344
  87.          Left            =   135
  88.          List            =   "MainForm.frx":036C
  89.          Style           =   2  'Dropdown List
  90.          TabIndex        =   23
  91.          Top             =   1275
  92.          Width           =   2430
  93.       End
  94.       Begin VB.OptionButton DisplayOptions 
  95.          Caption         =   "Overlay"
  96.          Height          =   225
  97.          Index           =   1
  98.          Left            =   1470
  99.          TabIndex        =   22
  100.          Top             =   1815
  101.          Width           =   885
  102.       End
  103.       Begin VB.OptionButton DisplayOptions 
  104.          Caption         =   "Preview"
  105.          Height          =   225
  106.          Index           =   0
  107.          Left            =   150
  108.          TabIndex        =   21
  109.          Top             =   1800
  110.          Value           =   -1  'True
  111.          Width           =   960
  112.       End
  113.       Begin VB.CheckBox CaptureAudio 
  114.          Caption         =   "Capture Audio"
  115.          Height          =   225
  116.          Left            =   150
  117.          TabIndex        =   18
  118.          Top             =   1005
  119.          Value           =   1  'Checked
  120.          Width           =   1455
  121.       End
  122.       Begin VB.TextBox FramesPS 
  123.          Height          =   285
  124.          Left            =   1545
  125.          TabIndex        =   16
  126.          Text            =   "0"
  127.          Top             =   180
  128.          Width           =   810
  129.       End
  130.       Begin VB.CheckBox TimeCheck 
  131.          Caption         =   "Time Limit"
  132.          Height          =   240
  133.          Left            =   150
  134.          TabIndex        =   15
  135.          Top             =   675
  136.          Width           =   1050
  137.       End
  138.       Begin VB.TextBox TimeLimit 
  139.          Enabled         =   0   'False
  140.          Height          =   285
  141.          Left            =   1545
  142.          TabIndex        =   14
  143.          Text            =   "0"
  144.          Top             =   600
  145.          Width           =   810
  146.       End
  147.       Begin VB.Line Line1 
  148.          X1              =   0
  149.          X2              =   2595
  150.          Y1              =   1695
  151.          Y2              =   1695
  152.       End
  153.       Begin VB.Label Label4 
  154.          Caption         =   "Frames Per Sec"
  155.          Height          =   180
  156.          Left            =   150
  157.          TabIndex        =   17
  158.          Top             =   270
  159.          Width           =   1185
  160.       End
  161.    End
  162.    Begin VB.Frame Dialogs 
  163.       Caption         =   "Dialogs"
  164.       Height          =   885
  165.       Left            =   30
  166.       TabIndex        =   9
  167.       Top             =   630
  168.       Width           =   3270
  169.       Begin VB.CommandButton FormatBtn 
  170.          Caption         =   "&Format"
  171.          Height          =   405
  172.          Left            =   195
  173.          TabIndex        =   12
  174.          Top             =   270
  175.          Width           =   900
  176.       End
  177.       Begin VB.CommandButton SourceBtn 
  178.          Caption         =   "&Source"
  179.          Height          =   405
  180.          Left            =   1995
  181.          TabIndex        =   11
  182.          Top             =   270
  183.          Width           =   900
  184.       End
  185.       Begin VB.CommandButton DisplayBtn 
  186.          Caption         =   "&Display"
  187.          Height          =   405
  188.          Left            =   1095
  189.          TabIndex        =   10
  190.          Top             =   270
  191.          Width           =   900
  192.       End
  193.    End
  194.    Begin VB.CommandButton StopBtn 
  195.       Caption         =   "Stop"
  196.       Height          =   420
  197.       Left            =   1080
  198.       TabIndex        =   8
  199.       Top             =   3015
  200.       Width           =   870
  201.    End
  202.    Begin VB.CommandButton StartBtn 
  203.       Caption         =   "Start"
  204.       Height          =   420
  205.       Left            =   75
  206.       TabIndex        =   7
  207.       Top             =   3015
  208.       Width           =   900
  209.    End
  210.    Begin VB.ComboBox DriverCombo 
  211.       Height          =   315
  212.       Left            =   30
  213.       Style           =   2  'Dropdown List
  214.       TabIndex        =   6
  215.       Top             =   270
  216.       Width           =   3255
  217.    End
  218.    Begin VB.Frame Frame1 
  219.       Caption         =   "Capture File"
  220.       Height          =   1335
  221.       Left            =   45
  222.       TabIndex        =   0
  223.       Top             =   1545
  224.       Width           =   3255
  225.       Begin VB.CommandButton Command1 
  226.          Caption         =   "..."
  227.          Height          =   255
  228.          Left            =   2760
  229.          TabIndex        =   4
  230.          Top             =   510
  231.          Width           =   255
  232.       End
  233.       Begin VB.TextBox WorkFileSize 
  234.          Height          =   285
  235.          Left            =   840
  236.          TabIndex        =   3
  237.          Top             =   840
  238.          Width           =   1815
  239.       End
  240.       Begin VB.Label CapFile 
  241.          BackColor       =   &H8000000A&
  242.          Caption         =   "Label5"
  243.          Height          =   255
  244.          Left            =   120
  245.          TabIndex        =   28
  246.          Top             =   510
  247.          Width           =   2535
  248.       End
  249.       Begin VB.Label Label2 
  250.          Caption         =   "File Size:"
  251.          Height          =   255
  252.          Left            =   120
  253.          TabIndex        =   2
  254.          Top             =   870
  255.          Width           =   1215
  256.       End
  257.       Begin VB.Label Label1 
  258.          Caption         =   "Filename:"
  259.          Height          =   255
  260.          Left            =   120
  261.          TabIndex        =   1
  262.          Top             =   240
  263.          Width           =   1095
  264.       End
  265.    End
  266.    Begin MSComDlg.CommonDialog CommonDialog1 
  267.       Left            =   3360
  268.       Top             =   1800
  269.       _ExtentX        =   847
  270.       _ExtentY        =   847
  271.       _Version        =   327681
  272.       CancelError     =   -1  'True
  273.       DefaultExt      =   "avi"
  274.       DialogTitle     =   "Capture Work File"
  275.       Filter          =   "AVI File | *.avi|"
  276.    End
  277.    Begin VB.Label Label3 
  278.       Caption         =   "Capture Drivers:"
  279.       Height          =   255
  280.       Left            =   30
  281.       TabIndex        =   5
  282.       Top             =   30
  283.       Width           =   1575
  284.    End
  285. Attribute VB_Name = "MainForm"
  286. Attribute VB_GlobalNameSpace = False
  287. Attribute VB_Creatable = False
  288. Attribute VB_PredeclaredId = True
  289. Attribute VB_Exposed = False
  290. Dim ActiveIndex As Integer
  291. Sub EnableButtons()
  292.     Dim i As Long
  293.     FormatBtn.Enabled = CaptureForm.LEADCap1.IsOptionAvailable(DLG_VIDFORMAT)
  294.     SourceBtn.Enabled = CaptureForm.LEADCap1.IsOptionAvailable(DLG_VIDSOURCE)
  295.     DisplayBtn.Enabled = CaptureForm.LEADCap1.IsOptionAvailable(DLG_VIDDISPLAY)
  296.     DisplayOptions(1).Enabled = CaptureForm.LEADCap1.IsOptionAvailable(DLG_VIDDISPLAY)
  297. End Sub
  298. Private Sub AudioFormat_Click()
  299.     On Error GoTo TheError
  300.     Select Case AudioFormat.ListIndex
  301.         Case 0
  302.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_1M08
  303.         Case 1
  304.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_1S08
  305.         Case 2
  306.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_1M16
  307.         Case 3
  308.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_1S16
  309.         Case 4
  310.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_2M08
  311.         Case 5
  312.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_2S08
  313.         Case 6
  314.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_2M16
  315.         Case 7
  316.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_2S16
  317.         Case 8
  318.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_4M08
  319.         Case 9
  320.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_4S08
  321.         Case 10
  322.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_4M16
  323.         Case 11
  324.             CaptureForm.LEADCap1.CapAudioFormat(CAP_AUDIO_CAPTURE) = FILE_WAV_4S16
  325.     End Select
  326.     Exit Sub
  327. TheError:
  328.     MsgBox CStr(Err.Description)
  329. End Sub
  330. Private Sub CaptureAudio_Click()
  331.    CaptureForm.LEADCap1.CapCaptureAudio = (CaptureAudio.Value = 1)
  332.    AudioFormat.Enabled = CaptureForm.LEADCap1.CapCaptureAudio
  333. End Sub
  334. Private Sub Check1_Click()
  335.     TimeLimit.Enabled = (Check1.Value = 1)
  336.     If TimeLimit.Enabled Then
  337.         CaptureForm.LEADCap1.CapTimeLimit = Str(TimeLimit.Text)
  338.     Else
  339.         CaptureForm.LEADCap1.CapTimeLimit = 0
  340.     End If
  341. End Sub
  342. Private Sub Command2_Click()
  343.     ' you shouldn't display a dialog during a capture operation,  If you stop and display
  344.     ' your dialog right away the info reported may not be totally accurate, because of buffered
  345.     ' data, you should wait for some to for the data to be written
  346.     CaptureForm.LEADCap1.CapStopCapture
  347.     CapInfoForm.Show 1
  348. End Sub
  349. Private Sub Command3_Click()
  350.     On Error GoTo TheError
  351.     'save the workfile to a permanent file
  352.     CommonDialog1.Filter = "AVI files|*.avi"
  353.     CommonDialog1.DefaultExt = ".avi"
  354.     CommonDialog1.ShowSave
  355.     If CommonDialog1.filename <> "" Then
  356.         Screen.MousePointer = 11
  357.         nRet = CaptureForm.LEADCap1.CapCopyWorkFileAs(CommonDialog1.filename)
  358.         Screen.MousePointer = 0
  359.         If nRet <> 0 Then
  360.             MsgBox "Error saving file!"
  361.         End If
  362.     End If
  363.     Exit Sub
  364. TheError:
  365.     MsgBox CStr(Err.Description)
  366. End Sub
  367. Private Sub Command4_Click()
  368. '    CaptureForm.LeadCap1.CapUpdateVidFormat
  369.     Dim Msg$
  370.     Msg$ = "LEADTOOLS VB Capture Demo"
  371.     Msg$ = Msg$ & Chr$(13)
  372.     Msg$ = Msg$ & "Copyright 1998, LEAD Technolgies, Inc."
  373.     Msg$ = Msg$ & Chr$(13)
  374.     Msg$ = Msg$ & Chr$(13)
  375.     Msg$ = Msg$ & "phone: 800-637-4699"
  376.     Msg$ = Msg$ & Chr$(13)
  377.     Msg$ = Msg$ & "http://www.leadtools.com"
  378.     Msg$ = Msg$ & Chr$(13)
  379.     Msg$ = Msg$ & "e-mail: support@leadtools.com"
  380.     MsgBox Msg$
  381. End Sub
  382. Private Sub CloseBtn_Click()
  383.     End
  384. End Sub
  385. Private Sub Command1_Click()
  386.     On Error GoTo GetOut
  387.     CommonDialog1.filename = CapFile.Caption
  388.     CommonDialog1.ShowSave
  389.     CaptureForm.LEADCap1.CapWorkFile = CommonDialog1.filename
  390.     CapFile.Caption = CommonDialog1.filename
  391. GetOut:
  392.     Exit Sub
  393. End Sub
  394. Private Sub DisplayBtn_Click()
  395.     CaptureForm.LEADCap1.CapDisplayDialog DLG_VIDDISPLAY, CAP_AUDIO_CAPTURE, CAP_AUDIO_CHOOSE_INPUT + CAP_AUDIO_CHOOSE_OUTPUT
  396. End Sub
  397. Private Sub DisplayOptions_Click(Index As Integer)
  398.     If DisplayOptions(Index).Value = True And Index = 0 Then
  399.         CaptureForm.LEADCap1.CapDisplayMode = DISPLAY_PREVIEW
  400.     ElseIf DisplayOptions(Index).Value = True And Index = 1 Then
  401.         CaptureForm.LEADCap1.CapDisplayMode = DISPLAY_OVERLAY
  402.     End If
  403. End Sub
  404. Private Sub DriverCombo_Click()
  405.     If ActiveIndex <> DriverCombo.ListIndex Then
  406.         ActiveIndex = DriverCombo.ListIndex
  407.         CaptureForm.LEADCap1.CapDisconnect
  408.         CaptureForm.LEADCap1.CapConnect ActiveIndex
  409.         EnableButtons
  410.     End If
  411. End Sub
  412. Private Sub Form_Load()
  413.     LEADCap1.UnlockSupport L_SUPPORT_EXPRESS, L_KEY_EXPRESS
  414.     LEADCap1.UnlockSupport L_SUPPORT_VIDEO, L_KEY_VIDEO
  415.     LEADCap1.Visible = False
  416.     CaptureForm.LEADCap1.AutoResizeControl = True
  417.     LEADCap1.CapEnumDrivers
  418.     CapFile.Caption = CaptureForm.LEADCap1.CapWorkFile
  419.     CaptureForm.LEADCap1.EnableMethodErrors = False
  420.     If DriverCombo.ListCount > 0 Then
  421.         DriverCombo.ListIndex = 0
  422.         nRet = CaptureForm.LEADCap1.CapConnect(DriverCombo.ListIndex)
  423.         If (nRet <> 0) Then
  424.             MsgBox "Error connecting to capture driver: " & DriverCombo.List(DriverCombo.ListIndex) & Chr$(13) & "Ending Application!"
  425.             End
  426.         End If
  427.     Else
  428.         DriverCombo.Enabled = False
  429.     End If
  430.     CaptureForm.LEADCap1.EnableMethodErrors = True
  431.     CaptureForm.LEADCap1.CapDisplayMode = DISPLAY_PREVIEW
  432.     FramesPS.Text = CStr(CaptureForm.LEADCap1.CapFramesPerSec)
  433.     EnableButtons
  434.     CaptureForm.Left = Left + Width
  435.     CaptureForm.Top = Top
  436.     CaptureForm.LEADCap1.EnableCaptureStatus = True
  437.     WorkFileSize.Text = CStr(CaptureForm.LEADCap1.CapWorkFileSize)
  438.     AudioFormat.ListIndex = 0
  439.     ActiveIndex = 0
  440.     CaptureForm.Show
  441. End Sub
  442. Private Sub Form_Unload(Cancel As Integer)
  443.     Unload CaptureForm
  444. End Sub
  445. Private Sub FormatBtn_Click()
  446.     CaptureForm.LEADCap1.CapDisplayDialog DLG_VIDFORMAT, 0, 0
  447. End Sub
  448. Private Sub LeadCap1_CapDriver(ByVal iDriver As Integer, ByVal pszName As String)
  449.     DriverCombo.AddItem pszName, iDriver
  450. End Sub
  451. Private Sub SourceBtn_Click()
  452.     CaptureForm.LEADCap1.CapDisplayDialog DLG_VIDSOURCE, 0, 0
  453. End Sub
  454. Private Sub StartBtn_Click()
  455.     On Error GoTo STARTERROR
  456.     CaptureForm.LEADCap1.CapAbortLeftMouse = False
  457.     CaptureForm.LEADCap1.CapAbortRightMouse = True
  458.     CaptureForm.LEADCap1.CapStartCapture
  459.     Exit Sub
  460. STARTERROR:
  461.     MsgBox Err.Description
  462. End Sub
  463. Private Sub StopBtn_Click()
  464.     On Error GoTo STOPERROR
  465.     CaptureForm.LEADCap1.CapStopCapture
  466.     Exit Sub
  467. STOPERROR:
  468.     MsgBox Err.Description
  469. End Sub
  470. Private Sub Text2_Change()
  471.     CaptureForm.LEADCap1.CapWorkFileSize = Val(Text2.Text)
  472. End Sub
  473. Private Sub TimeCheck_Click()
  474.     TimeLimit.Enabled = (TimeCheck.Value = 1)
  475.     If Not TimeLimit.Enabled Then
  476.         CaptureForm.LEADCap1.CapTimeLimit = 0
  477.     End If
  478. End Sub
  479. Private Sub TimeLimit_Change()
  480.     If TimeCheck.Value = 1 Then
  481.         CaptureForm.LEADCap1.CapTimeLimit = Val(TimeLimit.Text)
  482.     End If
  483. End Sub
  484. Private Sub WorkFileSize_Change()
  485.     CaptureForm.LEADCap1.CapWorkFileSize = Val(WorkFileSize.Text)
  486. End Sub
  487.