Signatures
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
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"
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"
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
This is the final test that works excellent. Thank you all for the help.
#include "C:\FWPPC\INCLUDE\FWCE.ch"
#include "C:\FWPPC\INCLUDE\DLL.ch"
function Main()
local oMain, oSig, nHdc, ;
nOldX := -1, ;
nOldY := -1
LOCAL DFILE := CURDIR() + "\MYSIGN.BMP"
DEFINE WINDOW oMain TITLE "Signature"
@40,5 SAY oSig PROMPT "" SIZE 230,150 PIXEL BORDER
@15, 5 BUTTON "Clear" SIZE 50,20 PIXEL ACTION oSig:refresh(.t.)
@15,60 BUTTON "Save" SIZE 50,20 PIXEL ACTION ( oSig:saveToBmp( DFIle ), oSig:refresh(.t.), ReleaseDC( oSig:hWnd, oSig:hDC ), 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
MoveTo( hDC, x, y )
Else
LineTo( hDc,x,y )
EndIf
RETURN Nil
#include "C:\FWPPC\INCLUDE\FWCE.ch"
#include "C:\FWPPC\INCLUDE\DLL.ch"
function Main()
local oMain, oSig, nHdc, ;
nOldX := -1, ;
nOldY := -1
LOCAL DFILE := CURDIR() + "\MYSIGN.BMP"
DEFINE WINDOW oMain TITLE "Signature"
@40,5 SAY oSig PROMPT "" SIZE 230,150 PIXEL BORDER
@15, 5 BUTTON "Clear" SIZE 50,20 PIXEL ACTION oSig:refresh(.t.)
@15,60 BUTTON "Save" SIZE 50,20 PIXEL ACTION ( oSig:saveToBmp( DFIle ), oSig:refresh(.t.), ReleaseDC( oSig:hWnd, oSig:hDC ), 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
MoveTo( hDC, x, y )
Else
LineTo( hDc,x,y )
EndIf
RETURN Nil
-
- Posts: 42
- Joined: Wed Oct 26, 2005 1:20 pm
- Location: Marshall, Virginia, USA
- Contact:
Richard, very nice! Thanks for cleaning up my code. Antonio, thanks for the info on the built-in FW functions. I'm still learning the FW syntax and functions.
Also, Antonio thank you for the incredible tool that FWPPC is. It has enabled us to deploy a Mobile app in very short time!
Merry Christmas to all!
Also, Antonio thank you for the incredible tool that FWPPC is. It has enabled us to deploy a Mobile app in very short time!
Merry Christmas to all!
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
Merchant Software Corp
Marshall, Virginia USA
-
- Posts: 12
- Joined: Wed Jul 09, 2008 7:07 pm
- Location: Manchester, UK
Monochrome bitmap
Thankyou Richard and Bill this code works very well.
The resulting BMP is 256 colours. I have a printer attached to my device and a DLL that will except the following.
PrintGraphic("MYSIG.BMP")
But you guessed it will only work if the BMP is 2 colours. Does anyone have a technique for converting the colour bit depth in FWPPC.
The resulting BMP is 256 colours. I have a printer attached to my device and a DLL that will except the following.
PrintGraphic("MYSIG.BMP")
But you guessed it will only work if the BMP is 2 colours. Does anyone have a technique for converting the colour bit depth in FWPPC.
Regards
Chris Millard
Chris Millard
-
- Posts: 37
- Joined: Sun Aug 03, 2008 8:02 am
- Location: Germany, Berlin
Hi All, specally Maurizio,
i must send the signature over Cell phone to a Webserver, so the data must be as small as possible (max. 1k packages). So i like the idea of Maurizio, only to send the array data. I already have implemented this and get filesizes of 1200 to 1500 Byte, which i can split into 2 files.
Questions: Is there a better solution for packing the data ?
If not, can someone point me to how to rebuild the signature from the array data or have a sample code for this ?
i must send the signature over Cell phone to a Webserver, so the data must be as small as possible (max. 1k packages). So i like the idea of Maurizio, only to send the array data. I already have implemented this and get filesizes of 1200 to 1500 Byte, which i can split into 2 files.
Questions: Is there a better solution for packing the data ?
If not, can someone point me to how to rebuild the signature from the array data or have a sample code for this ?
Best regards
Wolfgang Ciriack
Wolfgang Ciriack
Hello Wolfang
#include "report.ch"
Static Function PrintBmp(cFileBmp)
Local aDati := {}
Local oPrn,oPen,oFont
Local cTxt := ""
LOCAL nX
Local n1 := 0
Local n2 := 0
local nRow := 0, nCol := 0
Local nMaxRow := 0
Local nZoom := 2
IF file(cFileBmp)
cTxt := memoread(cFileBmp)
aDati := aRead(cTxt)
ELSE
Return FALSE
ENDIF
DEFINE PEN oPen WIDTH 3
PRINT oPrn NAME "Test" TO cStampante // "Comanda_1" // PREVIEW // TO "PDFCreator" //PREVIEW
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12 OF oPrn
PAGE
FOR nX := 2 TO len(aDAti) - 1
IF n1 > 0
IF aDati[nX,1] < 1000
oPrn:Line(nRow + aDAti[nX,1]*nZoom,aDati[nX,2]*nZoom,nRow + n2*nZoom,n1*nZoom,oPen )
IIF( nMaxRow < nRow + aDAti[nX,1]* nZoom , nMaxRow := nRow + aDAti[nX,1]*nZoom , )
ELSE
n1 := 0
n2 := 0
loop
ENDIF
ENDIF
n1 := aDAti[nX,2]
n2 := aDAti[nX,1]
NEXT
ENDPAGE
ENDPRINT
oFont:End()
Return TRUE
Regards MAurizio
#include "report.ch"
Static Function PrintBmp(cFileBmp)
Local aDati := {}
Local oPrn,oPen,oFont
Local cTxt := ""
LOCAL nX
Local n1 := 0
Local n2 := 0
local nRow := 0, nCol := 0
Local nMaxRow := 0
Local nZoom := 2
IF file(cFileBmp)
cTxt := memoread(cFileBmp)
aDati := aRead(cTxt)
ELSE
Return FALSE
ENDIF
DEFINE PEN oPen WIDTH 3
PRINT oPrn NAME "Test" TO cStampante // "Comanda_1" // PREVIEW // TO "PDFCreator" //PREVIEW
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12 OF oPrn
PAGE
FOR nX := 2 TO len(aDAti) - 1
IF n1 > 0
IF aDati[nX,1] < 1000
oPrn:Line(nRow + aDAti[nX,1]*nZoom,aDati[nX,2]*nZoom,nRow + n2*nZoom,n1*nZoom,oPen )
IIF( nMaxRow < nRow + aDAti[nX,1]* nZoom , nMaxRow := nRow + aDAti[nX,1]*nZoom , )
ELSE
n1 := 0
n2 := 0
loop
ENDIF
ENDIF
n1 := aDAti[nX,2]
n2 := aDAti[nX,1]
NEXT
ENDPAGE
ENDPRINT
oFont:End()
Return TRUE
Regards MAurizio
-
- Posts: 37
- Joined: Sun Aug 03, 2008 8:02 am
- Location: Germany, Berlin
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: