1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" ( _
ByVal lpszWindowName As String, _
ByVal dwStyle As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hwndParent As Long, _
ByVal nID As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any) As Long
Private Const WM_USER As Long = &H400
Private Const WM_CAP_DRIVER_CONNECT As Long = WM_USER + 10
Private Const WM_CAP_DRIVER_DISCONNECT As Long = WM_USER + 11
Private Const WM_CAP_GRAB_FRAME As Long = WM_USER + 60
Private Const WM_CAP_EDIT_COPY As Long = WM_USER + 30
Private iResult As Long
Private Sub Form_Load()
Timer1.Interval = 50
iResult = capCreateCaptureWindow("Capture", _
0, 0, 0, _
Picture1.ScaleWidth, _
Picture1.ScaleHeight, _
Me.hwnd, 0)
SendMessage iResult, WM_CAP_DRIVER_CONNECT, 0, 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
SendMessage iResult, WM_CAP_DRIVER_DISCONNECT, 0, 0
End Sub
Private Sub Timer1_Timer()
Clipboard.Clear
SendMessage iResult, WM_CAP_GRAB_FRAME, 0, 0
SendMessage iResult, WM_CAP_EDIT_COPY, 0, 0
Picture1.Picture = Clipboard.GetData
End Sub |
Partager