Local lcSource,LcPath,LcFile m.LcPath = Addbs(m.gcPhotoDir) + [Items\] m.LcFile = Alltrim(Thisform.pf.pgCards.txtItemCode.Value) + ".JPG" DO video_capture WITH m.lcPath,m.lcFile *!* video_capture.prg && also photo capture Lparameters tcPath,tcFile Local oForm oForm = Createobject("Tform") oForm.AddProperty('cPath',m.tcPath) && added by soykan oForm.AddProperty('cFile',m.tcFile) && added by soykan oForm.Show(1) * end of main Define Class Tform As Form #Define WM_CAP_START 0x0400 #Define WM_CAP_DRIVER_CONNECT (WM_CAP_START+10) #Define WM_CAP_DRIVER_DISCONNECT (WM_CAP_START+11) #Define WM_CAP_DRIVER_GET_CAPS (WM_CAP_START+14) #Define WM_CAP_SET_PREVIEW (WM_CAP_START+50) #Define WM_CAP_SET_OVERLAY (WM_CAP_START+51) #Define WM_CAP_SET_PREVIEWRATE (WM_CAP_START+52) #Define WM_CAP_GET_STATUS (WM_CAP_START+54) #Define WM_CAP_GRAB_FRAME (WM_CAP_START+60) Width=340 Height=310 AutoCenter=.T. Caption="Photo & Video Capture" MinButton=.F. MaxButton=.F. hWindow=0 hCapture=0 capWidth=0 capHeight=0 capOverlay=0 Add Object cmdGetFrame As CommandButton With Default=.T.,; Left=15, Top=264, Height=27, Width=90, Caption="Capture \<Photo",; Enabled=.F. Add Object cmdPreview As CommandButton With Default=.T.,; Left=106, Top=264, Height=27, Width=100, Caption="Capture \<Video",; Enabled=.F. *Add Object cmdSource As CommandButton With Default=.T.,; Left=206, Top=264, Height=27, Width=50, Caption="\<Select Source",; Enabled=.T. Add Object cmdClose As CommandButton With Cancel=.T.,; Left=250, Top=264, Height=27, Width=70, Caption="\<Quit" Procedure Activate If This.hWindow = 0 Declare Integer GetFocus In user32 This.hWindow = GetFocus() This.CreateCaptureWindow This.DriverConnect Thisform.StartPreview && added by soykan Endif Procedure Destroy This.ReleaseCaptureWindow Procedure cmdClose.Click Thisform.Release Procedure cmdGetFrame.Click Thisform.GetFrame Procedure cmdPreview.Click Thisform.StartPreview *Procedure cmdSource.Click *#Define WM_CAP_DLG_VIDEOSOURCE(WM_CAP_START + 10) *Thisform.msg(WM_CAP_DLG_VIDEOSOURCE) Procedure GetFrame *This.msg(WM_CAP_GRAB_FRAME, 0,0) * -- added by soykan * capture image #Define WM_CAP_FILE_SAVEDIB (WM_CAP_START + 25) Local lcFile lcFile = "" && File name to create If _vfp.StartMode # 0 lcFile = Thisform.cPath + Thisform.cFile Else lcFile = "c:\sample.bmp" Endif This.msg(WM_CAP_GRAB_FRAME, 0,0) If This.msg(WM_CAP_FILE_SAVEDIB, 0, m.lcFile,1) Messagebox('Fotoğraf ' + m.lcFile + ' Dizinine Kaydedildi',64,'Image Capture') Else Messagebox('Hata Oluştu...',16,'Hata') Endif *-- end of adding Procedure CreateCaptureWindow #Define WS_CHILD 0x40000000 #Define WS_VISIBLE 0x10000000 Declare Integer capCreateCaptureWindow In avicap32; STRING lpszWindowName, Long dwStyle,; INTEGER x, Integer Y,; INTEGER nWidth, Integer nHeight,; INTEGER hParent, Integer nID This.hCapture = capCreateCaptureWindow("",; WS_CHILD+WS_VISIBLE,; 10,8,320,240, This.hWindow, 1) Procedure DriverConnect This.msg(WM_CAP_DRIVER_CONNECT, 0,0) If This.IsCaptureConnected() This.GetCaptureDimensions Store .T. To This.cmdGetFrame.Enabled,; THIS.cmdPreview.Enabled This.Caption = This.Caption + ": Connection Succeed, Dimension : " +; LTRIM(Str(This.capWidth)) + "X" +; LTRIM(Str(This.capHeight)) Else This.Caption = This.Caption + ": Unable to Connection" Endif Procedure DriverDisconnect This.msg(WM_CAP_DRIVER_DISCONNECT, 0,0) Procedure ReleaseCaptureWindow Local myHWND && added by soykan myHWND = Thisform.HWnd && added by soykan If This.hCapture <> 0 This.DriverDisconnect Declare Integer DestroyWindow In user32 Integer myHWND &&HWnd = DestroyWindow(This.hCapture) This.hCapture = 0 Endif Procedure msg(msg, wParam, Lparam, nMode) Local myHWND && added by soykan myHWND = Thisform.HWnd && added by soykan If This.hCapture = 0 Return Endif If Vartype(nMode) <> "N" Or nMode=0 Declare Integer SendMessage In user32; INTEGER myHWnd, Integer Msg,; INTEGER wParam, Integer Lparam = SendMessage(This.hCapture, msg, wParam, Lparam) Else Declare Integer SendMessage In user32; Integer myHWnd, Integer Msg,; INTEGER wParam, String @Lparam = SendMessage(This.hCapture, msg, wParam, @Lparam) Endif Function IsCaptureConnected * analyzing fCaptureInitialized member of the CAPDRIVERCAPS structure #Define CAPDRIVERCAPS_SIZE 44 Local cBuffer, nResult cBuffer = Repli(Chr(0),CAPDRIVERCAPS_SIZE) This.msg(WM_CAP_DRIVER_GET_CAPS, Len(cBuffer), @cBuffer, 1) This.capOverlay = buf2dword(Substr(cBuffer,5,4)) nResult = Asc(Substr(cBuffer, 21,1)) Return (nResult<>0) Procedure GetCaptureDimensions * reading uiImageWidth and uiImageHeight members * of the CAPSTATUS structure #Define CAPSTATUS_SIZE 76 Local cBuffer cBuffer = Repli(Chr(0), CAPSTATUS_SIZE) This.msg(WM_CAP_GET_STATUS, Len(cBuffer), @cBuffer, 1) This.capWidth = buf2dword(Substr(cBuffer,1,4)) This.capHeight = buf2dword(Substr(cBuffer,5,4)) Procedure StartPreview This.msg(WM_CAP_SET_PREVIEWRATE, 30,0) This.msg(WM_CAP_SET_PREVIEW, 1,0) If This.capOverlay <> 0 This.msg(WM_CAP_SET_OVERLAY, 1,0) Endif Procedure StopPreview This.msg(WM_CAP_SET_PREVIEW, 0,0) Enddefine Function buf2dword(lcBuffer) Return Asc(Substr(lcBuffer, 1,1)) + ; BitLShift(Asc(Substr(lcBuffer, 2,1)), 8) +; BitLShift(Asc(Substr(lcBuffer, 3,1)), 16) +; BitLShift(Asc(Substr(lcBuffer, 4,1)), 24) *!* * VIDEO CAPTURE REFERENCES *!* *Basic Capture Operations *!* capCreateCaptureWindow *!* WM_CAP_ABORT *!* WM_CAP_DRIVER_CONNECT *!* WM_CAP_SEQUENCE *!* WM_CAP_STOP *!* *Capture Windows *!* CAPSTATUS *!* capGetDriverDescription *!* WM_CAP_DRIVER_CONNECT *!* WM_CAP_DRIVER_DISCONNECT *!* WM_CAP_GET_STATUS *!* *Capture Drivers *!* CAPDRIVERCAPS *!* WM_CAP_DRIVER_GET_CAPS *!* WM_CAP_DRIVER_GET_NAME *!* WM_CAP_DRIVER_GET_VERSION *!* WM_CAP_GET_AUDIOFORMAT *!* WM_CAP_GET_VIDEOFORMAT *!* WM_CAP_SET_AUDIOFORMAT *!* WM_CAP_SET_VIDEOFORMAT *!* *Capture Driver Preview and Overlay Modes *!* WM_CAP_SET_OVERLAY *!* WM_CAP_SET_PREVIEW *!* WM_CAP_SET_PREVIEWRATE *!* WM_CAP_SET_SCALE *!* WM_CAP_SET_SCROLL *!* *Capture Driver Video Dialog Boxes *!* WM_CAP_DLG_VIDEOCOMPRESSION *!* WM_CAP_DLG_VIDEODISPLAY *!* WM_CAP_DLG_VIDEOFORMAT *!* WM_CAP_DLG_VIDEOSOURCE *!* *Audio Format *!* WM_CAP_GET_AUDIOFORMAT *!* WM_CAP_SET_AUDIOFORMAT *!* Video Capture Settings *!* *CAPTUREPARMS *!* WM_CAP_GET_SEQUENCE_SETUP *!* WM_CAP_SET_SEQUENCE_SETUP *!* *Capture File and Buffers *!* CAPTUREPARMS *!* WM_CAP_FILE_ALLOCATE *!* WM_CAP_FILE_GET_CAPTURE_FILE *!* WM_CAP_FILE_SAVEAS *!* WM_CAP_FILE_SET_CAPTURE_FILE *!* *Directly Using Capture Data *!* WM_CAP_SEQUENCE_NOFILE *!* *Capture from MCI Device *!* WM_CAP_SET_MCI_DEVICE *!* *Manual Frame Capture *!* WM_CAP_SINGLE_FRAME *!* WM_CAP_SINGLE_FRAME_CLOSE *!* WM_CAP_SINGLE_FRAME_OPEN *!* *Still-Image Capture *!* WM_CAP_EDIT_COPY *!* WM_CAP_FILE_SAVEDIB *!* WM_CAP_GRAB_FRAME *!* WM_CAP_GRAB_FRAME_NOSTOP *!* *Advanced Capture Options *!* WM_CAP_FILE_SET_INFOCHUNK *!* WM_CAP_GET_USER_DATA *!* WM_CAP_SET_USER_DATA *!* *Working with Palettes *!* WM_CAP_EDIT_COPY *!* WM_CAP_PAL_AUTOCREATE *!* WM_CAP_PAL_MANUALCREATE *!* WM_CAP_PAL_OPEN *!* WM_CAP_PAL_PASTE *!* WM_CAP_PAL_SAVE *!* *Yielding to Other Applications *!* WM_CAP_GET_SEQUENCE_SETUP *!* WM_CAP_SET_CALLBACK_YIELD *!* WM_CAP_SET_SEQUENCE_SETUP *!* *AVICap Callback Functions *!* capControlCallback *!* capErrorCallback *!* capStatusCallback *!* capVideoStreamCallback *!* capWaveStreamCallback *!* capYieldCallback *!* WM_CAP_SET_CALLBACK_CAPCONTROL *!* WM_CAP_SET_CALLBACK_ERROR *!* WM_CAP_SET_CALLBACK_FRAME *!* WM_CAP_SET_CALLBACK_STATUS *!* WM_CAP_SET_CALLBACK_VIDEOSTREAM *!* WM_CAP_SET_CALLBACK_WAVESTREAM *!* WM_CAP_SET_CALLBACK_YIELD