This is the modified sample that seems to work pretty well. With mouse, hold the button down while you sign. With pen it inks when the tip is on the glass.
#include "FiveWin.ch"
function CaptureSignature()
local oDlg, oSig, lPaint := .f., cFile := Lower( "signature.bmp" ), hDC
DEFINE DIALOG oDlg TITLE "Signature" FROM 0, 0 TO 150, 350 PIXEL
@ 15, 5 SAY oSig PROMPT "" SIZE 150, 40 PIXEL BORDER OF oDlg
@ 01, 5 BUTTON "Clear" SIZE 25, 10 PIXEL ACTION oSig:refresh(.t.) OF oDlg
@ 01, 60 BUTTON "Save" SIZE 25, 10 PIXEL OF odlg ;
ACTION ( oSig:SaveToBmp( cFile ), oDlg:End() )
oSig:lWantClick := .T.
oSig:bLButtonUp := { | x, y, z | DoDraw( hDC, y, x, lPaint := .F. ) }
oSig:bMMoved := { | x, y, z | DoDraw( hDC, y, x , lPaint ) }
oSig:bLClicked := { | x, y, z | DoDraw( hDC, y, x, lPaint := .T., .t. ) }
ACTIVATE DIALOG oDlg CENTER ;
ON INIT ( hDC := GetDC( oSig:hWnd ) ) ;
VALID ( ReleaseDC( oSig:hWnd, hDC ), .T. )
return nil
static function DoDraw( hDc, x, y, lPaint, lReset )
if lReset != nil .and. lReset
MoveTo( hDC, x, y )
endif
if ! lPaint
MoveTo( hDC, x, y )
else
LineTo( hDc, x, y )
endIf
return nil