@吹水佬 帮我看看这段代码有什么问题?
帮主,帮我看看这段代码有什么问题,关闭时发生错误,系统就退出了。程序代码:
loformset=CREATEOBJECT("oformset") loformset.frmmain.show() loformset.frmctrl.show() ************************************************** *-- Formset: formset (d:\documents\visual foxpro 项目\usecamera.scx) *-- ParentClass: formset *-- BaseClass: formset *-- Time Stamp: 10/27/21 03:01:04 PM * DEFINE CLASS oformset AS formset DataSession = 1 AutoRelease = .T. Name = "Formset" ADD OBJECT ofrmmain AS frmmain WITH ; DoCreate = .T., ; AutoCenter = .T., ; Caption = "frmmain", ; Name = "frmmain" ADD OBJECT frmctrl AS form WITH ; Top = 0, ; Left = 0, ; Height = 480, ; Width = 680, ; DoCreate = .T., ; Caption = "viewindow", ; Name = "frmctrl" PROCEDURE frmctrl.activate READ EVENTS ENDPROC ENDDEFINE DEFINE class frmmain as form ADD OBJECT label1 AS label WITH ; AutoSize = .T., ; Caption = "摄像头控制实例", ; Height = 16, ; Left = 10, ; Top = 10, ; Width = 86, ; Name = "Label1" ADD OBJECT line1 AS line WITH ; Height = 0, ; Left = 10, ; Top = 30, ; Width = 351, ; Name = "Line1" ADD OBJECT line2 AS line WITH ; Height = 0, ; Left = 11, ; Top = 31, ; Width = 351, ; BorderColor = RGB(255,255,255), ; Name = "Line2" ADD OBJECT cmdcloseview AS commandbutton WITH ; AutoSize = .T., ; Top = 40, ; Left = 10, ; Height = 25, ; Width = 66, ; Caption = "closeview", ; Enabled = .F., ; Name = "cmdcloseview" ADD OBJECT cmdsave AS commandbutton WITH ; Top = 70, ; Left = 10, ; Height = 25, ; Width = 60, ; Caption = "save", ; Enabled = .F., ; Name = "cmdsave" ADD OBJECT cmdrec AS commandbutton WITH ; Top = 100, ; Left = 10, ; Height = 25, ; Width = 60, ; Caption = "record", ; Enabled = .F., ; Name = "cmdrec" ADD OBJECT cmdstp AS commandbutton WITH ; Top = 130, ; Left = 10, ; Height = 25, ; Width = 60, ; Caption = "stop", ; Enabled = .F., ; Name = "cmdstp" ADD OBJECT cmdview AS commandbutton WITH ; Top = 160, ; Left = 10, ; Height = 25, ; Width = 60, ; Caption = "View", ; Name = "cmdview" ADD OBJECT cmdquit AS commandbutton WITH ; Top = 190, ; Left = 10, ; Height = 25, ; Width = 60, ; Caption = "quit", ; Name = "cmdquit" PROCEDURE Load *--定义:一般放到主程序或表单(集)的Load事件中 Public WM_CAP_DRIVER_DISCONNECT Public hwndc,WM_CAP_SAVEDIB,WM_CAP_FILE_SET_CAPTURE_FILEA,WM_CAP_SEQUENCE,WM_CAP_STOP Declare Integer capCreateCaptureWindowA In "AVICAP32.DLL" String lpszWindowName ,Integer dwStyle ,; Integer x, Integer Y, Integer nWidth ,Integer nHeight,Integer ParentWin,Integer nId Declare Integer SendMessage In "user32" Integer HWnd, Integer wmsg,Integer wpar1, Integer wpar2 Declare Integer SendMessage In "user32" As SendMessageA Integer HWnd, Integer wmsg,Integer wpar1, String wpar2 ENDPROC PROCEDURE Unload thisformset.Release CLEAR EVENTS ENDPROC PROCEDURE cmdcloseview.Click SendMessage(hWndC,WM_CAP_DRIVER_DISCONNECT, 0, 0) hWndC=0 thisform.cmdview.Enabled=.t. ENDPROC PROCEDURE cmdsave.Click *--保存图像: *--无法控制生成的文件尺寸,因为是由摄像头本身默认的,不过可用Image控件显示时进行等比缩小的。 ss=Getfile("bmp;Jpg") If !Empty(ss) SendMessageA(hWndC,WM_CAP_SAVEDIB,0,SS) Endif ENDPROC PROCEDURE cmdrec.Click *--录像: ss = Getfile("avi") If !Empty(ss) This.Enabled=.F. Thisform.MousePointer= 0 Thisform.cmdstp.Enabled=.T. thisform.cmdstp.setfocus SendMessageA(hWndC,WM_CAP_FILE_SET_CAPTURE_FILEA,0,ss) SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0) ENDIF ENDPROC PROCEDURE cmdstp.Click *--停止录像: SendMessage(hWndC, WM_CAP_STOP, 0, 0) Thisform.cmdrec.Enabled=.T. This.Enabled=.F. ENDPROC PROCEDURE cmdview.Click WM_USER = 1024 WM_CAP_START = WM_USER _CAP_STOP = WM_CAP_START + 68 WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10 WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11 WM_CAP_SAVEDIB = WM_CAP_START + 25 WM_CAP_GRAB_FRAME = WM_CAP_START + 60 WM_CAP_SEQUENCE = WM_CAP_START + 62 WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20 WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63 WM_CAP_SET_OVERLAY =WM_CAP_START+ 51 WM_CAP_SET_PREVIEW =WM_CAP_START+ 50 WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6 WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2 WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3 WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5 WM_CAP_SET_SCALE=WM_CAP_START+ 53 WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52 hWndC = capCreateCaptureWindowA('My Own Capture Window',0x50000000,0,0,640,480,thisformset.frmctrl.HWnd ,0) &&1342177280=0x50000000 If hWndC <> 0 SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0) SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0) SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0) SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0) SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0) SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0) SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0) SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0) * THISFORM.ACTIVATE ENDIF this.Enabled=.f. thisform.setall("enabled",.t.,"commandbutton") ENDPROC PROCEDURE cmdquit.Click thisform.Release ENDPROC ENDDEFINE * *-- EndDefine: formset **************************************************