by Richard Chidiak » Sun Dec 24, 2006 7:20 am
Question to Antonio
nHdc := GetDC( oSig:hWnd )
Will the Dc be automatically released at the end of the function or do we have to releasedc() ?
Thanks for reply
I made some minor changes to Bill's sample, setting locals variables instead of public , quitting after signature, here is mine
#include "C:\FWPPC\INCLUDE\FWCE.ch"
#include "C:\FWPPC\INCLUDE\DLL.ch"
function Main()
local oMain, oSig, nHdc, ;
nOldX := -1, ;
nOldY := -1
DEFINE WINDOW oMain TITLE "Signature"
@40,5 SAY oSig PROMPT "" SIZE 230,150 PIXEL BORDER
@15, 5 BUTTON "Effacer" SIZE 50,20 PIXEL ACTION oSig:refresh(.t.)
@15,60 BUTTON "Sauver" SIZE 50,20 PIXEL ACTION ( oSig:saveToBmp( CurDir() + "\MySig.BMP" ), oSig:refresh(.t.), OMAIN:END() )
nHdc := GetDC( oSig:hWnd )
oSig:bLButtonUp := { |x,y,z| DoDraw( nHdc, y+1, x+1,@noldx,@noldy ), nOldX := -1, nOldY := -1 }
oSig:bMMoved := { |x,y,z| DoDraw( nHdc, y, x ,@noldx,@noldy) }
oSig:bLClicked := { |x,y,z| DoDraw( nHdc, y, x ,@noldx,@noldy) }
ACTIVATE WINDOW oMain
return nil
STATIC Function DoDraw( hDc, x, y, noldx, noldy )
If nOldX == -1 .And. nOldY == -1
nOldX := x
nOldY := y
MoveToEx( hDc, x, y )
Else
LineTo( hDc,x,y )
EndIf
RETURN Nil
DLL STATIC FUNCTION MoveToEx( hWnd AS HDC, nX AS _INT, nY AS _INT, NULL AS _INT ) AS BOOL PASCAL LIB "coredll.dll"