Jump to content
Fivewin Brasil

Fazer assinatura em .BMP


kapiaba

Recommended Posts


#include "FiveWin.ch"

function CaptureSignature()

local oDlg, oSig, lPaint := .F., cFile := Lower( "signature.bmp" ), hDC
local lReset := .f.
local oBrush
local nPenWidth := 4, oPenSig
local nTop := 2, nBottom := 0
local aCoord
local nColor := CLR_WHITE

oBrush := TBrush():New( , nColor )
DEFINE DIALOG oDlg TITLE "Signature" PIXEL ;
RESOURCE "DLG_Sign"

DEFINE PEN oPenSig WIDTH nPenWidth COLOR CLR_BLACK

REDEFINE SAY oSig ID 200 PROMPT "" OF oDlg
oSig:nClrPane := nRgb( 255,255,255 )
oSig:oBrush := oBrush

redefine button prompt 'Save';
id 100 of oDlg update;
ACTION ( oSig:SaveToBmp( cFile ), oDlg:End() )

redefine button prompt 'Cancel';
id 101 of oDlg ;
action ( lReturn := .f., oDlg:End() )

redefine button prompt 'Clear';
id 102 of oDlg ;
action ( lPaint := .F., ;
FillRect( hDC, GetClientRect( oSig:hWnd ), oBrush:hBrush ), ;
oSig:refresh(.t.) )

oSig:lWantClick := .T.
// Fixed row, col to y, x conversion, x/y designation was reversed
oSig:bLButtonUp := { | y, x, z | DoDraw( hDC, x, y, lPaint := .F.,, oPenSig ) }
// Added limits to Top and Bottom in case users draw off canvas
oSig:bMMoved := { | y, x, z | ( ;
if( y >= nBottom .or. y <= nTop , lReset := .T., lReset := .f. ), ;
DoDraw( hDC, x, y , lPaint, lReset, oPenSig )) }
oSig:bLClicked := { | y, x, z | DoDraw( hDC, x, y, lPaint := .T., .t., oPenSig ) }
// If button released when not on Signature area
oDlg:bLButtonUp := { || lPaint := .F. }

ACTIVATE DIALOG oDlg CENTER ;
ON INIT ( aCoord := GetCoors( oSig:hWnd ), ;
nBottom := aCoord[3]- aCoord[1]-2, ;
hDC := GetDC( oSig:hWnd ), oSig:nClrPane := nColor ) ;
VALID ( ReleaseDC( oSig:hWnd, hDC ), .T. )
RELEASE PEN oPenSig

return nil

static function DoDraw( hDc, x, y, lPaint, lReset, oPen )
if ! lPaint .or. ( lReset != nil .and. lReset )
MoveTo( hDC, x, y )
else
LineTo( hDc, x, y, oPen:hPen )
endIf
return nil

/* // .RC
DLG_Sign DIALOG -32768, 65, 204, 99
STYLE DS_SYSMODAL | DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "Signature"
FONT 12, "MS Sans Serif"
{
PUSHBUTTON "Save", 100, 6, 3, 46, 14
PUSHBUTTON "Cancel", 101, 84, 3, 35, 14
PUSHBUTTON "Clear", 102, 162, 3, 35, 14
GROUPBOX "", 104, 4, 17, 198, 68, BS_GROUPBOX
CONTROL "", 200, "STATIC", SS_WHITERECT | WS_CHILD | WS_VISIBLE, 5, 22, 196, 61
RTEXT "X", -1, 1, 78, 5, 9
CTEXT "I agree that this inspection is correct.", -1, 13, 88, 172, 9
}
*/


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...