但是你又不想用timer,应该也不会想影响程序的工作吧。
给个方向性建议,建立一个新搭哗或的线程,然后让它运行一个过程,这个过程有一个循环,不断循环判断直到内存某数据改变。可以用sleep这个api函数来控制这个循环每次的间隔。这样就可以不影响前台工作。
你可以从外部终止这个线程,达到终止循环的目的
有什么问题?请HI我!--------------------
控件:3个命令按钮、一个图片框
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 Const WS_CHILD = &H40000000
Private Const WS_VISIBLE = &H10000000
Private Const WM_USER = &H400
Private Const WM_CAP_START = &H400
Private Const WM_CAP_EDIT_COPY = (WM_CAP_START + 30)
Private Const WM_CAP_DRIVER_CONNECT = (WM_CAP_START + 10)
Private Const WM_CAP_SET_PREVIEWRATE = (WM_CAP_START + 52)
Private Const WM_CAP_SET_OVERLAY = (WM_CAP_START + 51)
Private Const WM_CAP_SET_PREVIEW = (WM_CAP_START + 50)
Private Const WM_CAP_DRIVER_DISCONNECT = (WM_CAP_START + 11)
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Preview_Handle As Long
Private Function CreateCaptureWindow( _
hWndParent As Long, _
Optional x As Long = 0, _
Optional y As Long = 0, _
Optional nWidth As Long = 320, _
Optional nHeight As Long = 240, _
Optional nCameraID As Long = 0) As Long
Preview_Handle = capCreateCaptureWindow("Video", _
WS_CHILD + WS_VISIBLE, x, y, _
nWidth, nHeight, hWndParent, 1)
SendMessage Preview_Handle, WM_CAP_DRIVER_CONNECT, nCameraID, 0
SendMessage Preview_Handle, WM_CAP_SET_PREVIEWRATE, 30, 0
SendMessage Preview_Handle, WM_CAP_SET_OVERLAY, 1, 0
SendMessage Preview_Handle, WM_CAP_SET_PREVIEW, 1, 0
CreateCaptureWindow = Preview_Handle
End Function
Private Function CapturePicture(nCaptureHandle As Long) As StdPicture
Clipboard.Clear
SendMessage nCaptureHandle, WM_CAP_EDIT_COPY, 0, 0
Set CapturePicture = Clipboard.GetData
End Function
Private Sub Disconnect(nCaptureHandle As Long, _
Optional nCameraID = 0)
SendMessage nCaptureHandle, WM_CAP_DRIVER_DISCONNECT, _
nCameraID, 0
End Sub
Dim Video_Handle As Long
Private Sub Command2_Click()
Video_Handle = CreateCaptureWindow(PicCapture.hwnd, , , Me.PicCapture.Width, Me.PicCapture.Height)
End Sub
Private Sub Command1_Click()
Dim x As StdPicture
Set x = CapturePicture(Video_Handle)
SavePicture x, App.Path &"\a.bmp"
End Sub
Private Sub Command3_Click()
Disconnect Video_Handle
End Sub
Private Sub Form_Resize()
Me.PicCapture.Width = Me.Width - 400
Me.PicCapture.Height = Me.Height - 1400
Me.PicCapture.Refresh
End Sub
Private Sub Form_Unload(Cancel As Integer)
Disconnect Video_Handle
End Sub
不改动主程序要受控制端,自动关闭,显然是不可能的。肯定需要协议来关闭拍笑的。既然袭肆含自控软件带了接口,不就可以用协议来关闭吗?雹塌改动很简单。加一段小代码,既然受控肯定有信息窗体,当主程序关闭,发送一个信息出去,然后受控端设置一下 当收到这个信息关闭程序。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)