#include "FWCE.ch"
#include "DLL.ch"
function Main()
local oWnd, oSay, nHdc
PUBLIC nOldX := -1, nOldY := -1
DEFINE WINDOW oWnd TITLE "Draw"
@ 5,5 SAY oSay PROMPT "?" COLOR "N+/W*" PIXEL SIZE 60,15
@30,5 BUTTON "Clear" SIZE 50,20 PIXEL ACTION oWnd:refresh(.t.)
nHdc := GetDC(oWnd:hWnd)
oWnd:bLButtonUp := { |x,y,z| oSay:setText( "Up" ), DoDraw( nHdc, y, x ), nOldX := -1, nOldY := -1 }
oWnd:bMMoved := { |x,y,z| DoDraw( nHdc, y, x ) }
oWnd:activate( {|x,y,z| oSay:setText( "Down" ), DoDraw( nHdc, y, x ) } )
return nil
Function DoDraw( hDc, x, y )
If nOldX == -1 .And. nOldY == -1
nOldX := x
nOldY := y
MoveToEx( hDc, x, y )
Else
LineTo( hDc,x,y )
EndIf
RETURN Nil
DLL FUNCTION MoveToEx( nHdc AS HDC, nX AS _INT, nY AS _INT, NULL AS _INT ) AS BOOL PASCAL LIB "coredll.dll"
Antonio Linares wrote:Bill,
Excellent! It works very nicely!
We are going to include it in the FWPPC samples if you don't mind it, thanks!
#include "FWCE.ch"
static oWnd
function Main()
local hDC, lPaint := .f.
DEFINE WINDOW oWnd TITLE "Please sign" ;
MENU BuildMenu()
hDC = oWnd:GetDC()
oWnd:bLButtonUp = { | nRow, nCol | LineTo( hDC, nCol, nRow ), lPaint := .f. }
oWnd:bMMoved = { | nRow, nCol | If( lPaint, LineTo( hDC, nCol, nRow ),) }
ACTIVATE WINDOW oWnd ;
ON CLICK ( lPaint := .t., MoveTo( hDC, nCol, nRow ) ) ;
VALID ( oWnd:ReleaseDC(), .t. )
return nil
function BuildMenu()
local oMenu
DEFINE MENU oMenu RESOURCE 102 ;
BITMAPS 10 ; // bitmap resources ID
IMAGES 2 // number of images in the bitmap
REDEFINE MENUITEM ID 110 OF oMenu ;
ACTION ( oWnd:SaveToBmp( CurDir() + "\sign.bmp" ), oWnd:End() )
REDEFINE MENUITEM ID 120 OF oMenu ACTION oWnd:End()
return oMenu
#ifdef _CE
#include "c:\vce\include\arm\windows.h"
#include "c:\vce\include\arm\commctrl.h"
#endif
#define I_IMAGENONE (-2)
#define IDS_HELP 104
#ifdef _CE
102 RCDATA
BEGIN
102, 3,
0, 110, TBSTATE_ENABLED, TBSTYLE_BUTTON, 201, 0, 0,
0, 105, TBSTATE_ENABLED, TBSTYLE_SEP, -1, 0, 0,
1, 120, TBSTATE_ENABLED, TBSTYLE_BUTTON, 202, 0, 0
END
#endif
STRINGTABLE DISCARDABLE
BEGIN
201 "Save"
202 "Cancel"
END
102 MENU DISCARDABLE
BEGIN
MENUITEM "", 110
MENUITEM "", 120
END
10 BITMAP "../bitmaps/pocket/okcancel.bmp"
#include "FWCE.ch"
static oWnd, lDown, hDC ,cFile,nOldRow,nOldCol
Static aDati := {}
//====================================================================================
Function Main()
lDown := .F.
nOldRow := 0
nOldCol := 0
DEFINE WINDOW oWnd TITLE "Signature"
oWnd:bLClicked := { || lDown := .T. }
oWnd:bLButtonUp := { || lDown := .F. ,nOldRow := 0 , nOldCOl := 0 }
oWnd:bMMoved := { |nRow, nCol, nKeyFlags| Draw(nCol,nRow)}
hDC := oWnd:GetDC()
@ 1, 1 BUTTON oBtn1 PROMPT "Refresh" ;
ACTION (oWnd:Refresh(),aDAti := {}) SIZE 80, 20
@ 3, 1 BUTTON oBtn1 PROMPT "S a v e" ;
ACTION Save() SIZE 80, 20
ACTIVATE WINDOW oWnd
return 0
//====================================================================================
STATIC FUNCTION Draw(nRow,nCol)
IF lDown
* SetPixel(hDC, nRow, nCol, RGB(0,0,0) )
IF nOldRow > 0
DrawLine(nRow,nCol)
aadd(aDAti,{nRow,nCol})
ELSE
// We will need to know when a line starts and finishes
aadd(aDAti,{nRow+1000,nCol+1000})
ENDIF
nOldRow := nRow
nOldCol := nCol
ENDIF
RETURN NIL
//=================================================
Static Procedure DrawLine( nRow,nCol )
LOCAL n, hPen, hOldPen
oWnd:GetDc()
hPen := CreatePen( 0, 1, RGB(0,0,0) )
hOldPen := SelectObject( oWnd:hDc, hPen )
MoveTo( oWnd:hDC,nOldRow,nOldCol )
LineTo( oWnd:hDC, nRow, nCol )
SelectObject( oWnd:hDc, hOldPen )
DeleteObject( hPen )
oWnd:ReleaseDc()
RETURN
//=================================================
Function Save()
Local nX := 0
Local cTxt := aSave(aDAti)
MemoWrit( CurDir() + "\Prova.txt", cTxt )
RETURN NIL
//-------------------------------------------------------------------------------------------
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
#include "item.api"
HB_FUNC( SETPIXEL )
{
hb_retnl( SetPixel( ( HDC ) hb_parnl( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parnl( 4 ) ) );
}
#pragma ENDDUMP
function ASave( aArray )
local n, cType, uData
local cInfo := ""
for n = 1 to Len( aArray )
cType = ValType( aArray[ n ] )
do case
case cType == "A"
cInfo += ASave( aArray[ n ] )
case cType == "O"
cInfo += aArray[ n ]:Save()
otherwise
cInfo += ( cType + I2Bin( Len( uData := cValToChar( aArray[ n ] ) ) ) + ;
uData )
endcase
next
return "A" + I2Bin( 2 + Len( cInfo ) ) + I2Bin( Len( aArray ) ) + cInfo
//----------------------------------------------------------------------------//
#include "FWCE.ch"
#include "DLL.ch"
function Main()
local oMain, oSig, nHdc
local cDir := CurDir()
PUBLIC nOldX := -1, nOldY := -1
DEFINE WINDOW oMain TITLE "Draw"
@60,5 SAY oSig PROMPT "" SIZE 230,150 PIXEL BORDER
@25, 5 BUTTON "Clear" SIZE 50,20 PIXEL ACTION oSig:refresh(.t.)
@25,60 BUTTON "Save" SIZE 50,20 PIXEL ACTION ( oSig:saveToBmp( cDir + "\MySig.BMP" ), oSig:refresh(.t.) )
nHdc := GetDC( oSig:hWnd )
oSig:bLButtonUp := { |x,y,z| DoDraw( nHdc, y+1, x+1 ), nOldX := -1, nOldY := -1 }
oSig:bMMoved := { |x,y,z| DoDraw( nHdc, y, x ) }
oSig:bLClicked := { |x,y,z| DoDraw( nHdc, y, x ) }
ACTIVATE WINDOW oMain
return nil
Function DoDraw( hDc, x, y )
If nOldX == -1 .And. nOldY == -1
nOldX := x
nOldY := y
MoveToEx( hDc, x, y )
Else
LineTo( hDc,x,y )
EndIf
RETURN Nil
DLL FUNCTION MoveToEx( hWnd AS HDC, nX AS _INT, nY AS _INT, NULL AS _INT ) AS BOOL PASCAL LIB "coredll.dll"
Return to FiveWin for Pocket PC
Users browsing this forum: No registered users and 12 guests