********************************************************************* Function Get_Photo(oFrame, cCustomer_Picture, oDlg_Passed) ********************************************************************* LOCAL cText, oMle, aFormats, aMess LOCAL oBMP, oPS,cString, n, oClipBoard, nStatus, cdefsourec, lClipboard:=.f., nresult, aWin_Size, lExit:=.f., lQuit:=.f., lFail:=.f. Local nEvent := Nil, mp1 := NIL, mp2 := NIL, oXbp Local oDlg, aPos[2], aSize[2], oDraw, oVideo LOCAL bError := ErrorBlock( {|e| Break(e) } ) LOCAL oError aWin_Size := AppDeskTop():currentSize() lClipboard:=.f. ******************************************* * Open Clipboard and get available formats ******************************************* oClipBoard := XbpClipBoard():new():create() oClipBoard:open() aFormats := oClipBoard:queryFormats() ****************************************** * Scan for a bit map in the clipboard ****************************************** IF AScan( aFormats, XBPCLPBRD_BITMAP ) > 0 ********************************************** * Get bitmap object from clipboard if detected ********************************************** oBmp := oClipBoard:getBuffer( XBPCLPBRD_BITMAP) * Delete existing customer photo FErase( cCustomer_Picture) * Save new customer photo oBMP:SaveFile(cCustomer_Picture, XBPBMP_FORMAT_JPG) oBMP:Destroy() oFrame:unload() oFrame:loadfile(cCustomer_Picture) oFrame:draw() lClipboard:=.t. ELSE * no bitmap detected ENDIF * close clipboard oClipBoard:clear() oClipBoard:Close() oClipBoard:Destroy() If !lClipboard ***************************************************** * Following is the direct drive way of getting to camera ***************************************************** aSize[1] := 350 aSize[2] := 330 aPos[1] := (aWin_Size[1]/2) - (aSize[1]/2) aPos[2] := (aWin_Size[2]/2) - (aSize[2]/2) oDlg := XbpDialog():new(AppDeskTop(),oDlg_Passed , aPos, aSize ) oDlg:title := "Take Customer Picture" oDlg:taskList := .T. oDlg:close := {|| lExit:=.t. } oDlg:create() oDlg:drawingArea:setFontCompoundName( FONT_HELV_SMALL ) oDraw:=oDlg:drawingArea // SetAppWindow( oDlg ) /* * Create pushbuttons in the application window */ oXbp := XbpPushbutton():new( oDlg, , {62,12}, {100,30} ) oXbp:caption := "Snap Picture" oXbp:activate := {||oVideo:SaveFrameJPG(cCustomer_Picture,75),Sleep(10),lExit:=.t.} oXbp:create() oXbp := XbpPushbutton():new(oDlg , , {186,12}, {100,30} ) oXbp:caption := "Quit" oXbp:activate := {|| lQuit:=.t., lExit:=.t. } oXbp:create() /* * Create Video Activex control */ BEGIN SEQUENCE oVideo:=XbpActiveXControl():new( oDraw, , {12,50}, {320,240}) oVideo:CLSID := "VIDEOCAPX.VideoCapXCtrl.1" oVideo:License:="Your license goes here... if evaluation do not use this line" oVideo : create() Sleep(10) // oVideo:UseVideoFilter:=0 && no picture is captured into file if this is set to 0 oVideo:AudioDeviceIndex:=-1 && Indicates no audio device is to be used oVideo:CaptureAudio:=.f. && sets the audio capture off // oVideo:DebugMode:=1 && for debugging purposes only....take out when finished oVideo:SetVideoFormat(320, 240) oVideo:connected:=.t. oVideo:Preview:= .t. RECOVER USING oError msgbox("error detected...no camera or activex control") lQuit:=.t. lExit:=.t. lFail:=.t. ENDSEQUENCE ErrorBlock( bError ) // reset error code block SetAppFocus( oDlg ) DO WHILE !lExit nEvent := AppEvent( @mp1, @mp2, @oXbp ) oXbp:handleEvent( nEvent, mp1, mp2 ) ENDDO If !lFail oVideo:connected:=.f. sleep(10) oVideo:destroy() Endif oDlg:destroy() oVideo:=nil oDlg:=nil If !lQuit oFrame:unload() oFrame:loadfile(cCustomer_Picture) oFrame:draw() Endif Endif Return nil