- Code: Select all Expand view
#include "FiveWin.ch"
#include "Card.ch"
//----------------------------------------------------------------------------//
function Main()
Local mCogn:="Falconi", mNome:="Silvio", mdNasc:=DATE(), mSEX:="M"
LOCAL mCODFISC:="ASDFGH7B89L456T"
Local mCITTA:="Teramo",mPROV:="TE"
local oDlg, oCard , oBTN1 ,oBTN2
DEFINE DIALOG oDlg TITLE "CARD TEST" COLOR "W+/B" FROM 2,10 TO 24,80
@ 10, 2 CARDPREVIEW oCard ;
ON PAINT ANTEPRIMA( oCard,mCogn, mNome, mdNasc,mSEX,mCODFISC,mCITTA,mPROV) ;
SIZE 180,100 ;
VIEWSIZE 800,600 ;
RANGE 10, 10 ;
OF oDlg
*;
* COLOR CLR_RED,CLR_BLUE
@ 8,4 BUTTON oBTN1 PROMPT"ZOOM IN" OF oDlg ;
ACTION ( oCard:nViewWidth -= 100, oCard:nViewHeight -= 100, oCard:Refresh())
@ 8,24 BUTTON oBTN2 PROMPT"ZOOM OUT " OF oDlg ;
ACTION ( oCard:nViewWidth += 100, oCard:nViewHeight += 100, oCard:Refresh())
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//
function ANTEPRIMA( oCard,mCogn, mNome, mdNasc,mSEX,mCODFISC,mCITTA,mPROV)
local oFont
DEFINE FONT oFont NAME "Arial" SIZE 8, 10 bold
oCard:SayBitmap( 0, 0, "cod.bmp" )
oCard:Say( 8, 12, mCODFISC,,, oFont )
oCard:Say( 9, 12, ALLTRIM(mCogn),,, oFont )
oCard:Say( 10, 12,ALLTRIM( mNome),,, oFont )
oCard:Say( 10, 43,ALLTRIM(mSEX),,, oFont )
oCard:Say( 12, 12,ALLTRIM(mCITTA),,, oFont )
oCard:Say( 13, 12,ALLTRIM(mPROV),,, oFont )
oCard:Say( 13, 36,DTOC(mdNasc),,, oFont )
RELEASE FONT oFont
return nil
this the class TcardPreview :
card.ch
- Code: Select all Expand view
//----------------------------------------------------------------------------//
// Card Preview - Falconi Silvio
#xcommand REDEFINE CARDPREVIEW [<oPrintPrev>] ;
[ ON PAINT <uPaint> ] ;
[ VIEWSIZE <nViewWidth>, <nViewHeight> ] ;
[ RANGE <nMinPage>, <nMaxPage> ] ;
[ ID <nId> ] ;
[ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
[ <color:COLOR, COLORS> <nClrFore> [,<nClrBack>] ] ;
=> ;
[<oPrintPrev> := ] TCardPreview():ReDefine( <{uPaint}>, <nMinPage>,;
<nMaxPage>, <nViewWidth>, <nViewHeight>, <nId>, <oWnd>,;
<nClrFore>, <nClrBack> )
#xcommand @ <nRow>, <nCol> CARDPREVIEW [<oPrintPrev>] ;
[ ON PAINT <uPaint> ] ;
[ SIZE <nWidth>, <nHeight> ] ;
[ VIEWSIZE <nViewWidth>, <nViewHeight> ] ;
[ RANGE <nMinPage>, <nMaxPage> ] ;
[ ID <nId> ] ;
[ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
[ <color:COLOR, COLORS> <nClrFore> [,<nClrBack>] ] ;
=> ;
[<oPrintPrev> := ] TCardPreview():New( <nRow>, <nCol>, <nWidth>, <nHeight>,;
<{uPaint}>, <nMinPage>, <nMaxPage>, <nViewWidth>, <nViewHeight>,;
<oWnd>, <nClrFore>, <nClrBack> )
//----------------------------------------------------------------------------//
Tcardpreview.prg
- Code: Select all Expand view
#include "FiveWin.ch"
#define COLOR_WINDOW 5
#define COLOR_WINDOWTEXT 8
#define MM_ISOTROPIC 7
#define MM_ANISOTROPIC 8
static lRegistered := .f.
//----------------------------------------------------------------------------//
CLASS TCardPreview FROM TControl
DATA nMinPage, nMaxPage
DATA nViewWidth, nViewHeight
METHOD New( nRow, nCol, nWidth, nHeight, bPaint, nMinPage, nMaxPage,;
nViewWidth, nViewHeight, oWnd, nClrFore, nClrBack ) CONSTRUCTOR
METHOD ReDefine( bPaint, nMinPage, nMaxPage, nViewWidth, nViewHeight,;
nId, oWnd, nClrFore, nClrBack ) CONSTRUCTOR
METHOD HandleEvent( nMsg, nWParam, nLParam )
METHOD Paint()
METHOD StartPage() INLINE ::GetDC()
METHOD EndPage() INLINE ::ReleaseDC()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( nRow, nCol, nWidth, nHeight, bPaint, nMinPage, nMaxPage,;
nViewWidth, nViewHeight, oWnd, nClrFore, nClrBack ) CLASS TCardPreview
DEFAULT nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
nClrBack := GetSysColor( COLOR_WINDOW ),;
nWidth := 200, nHeight := 200
::nTop = nRow
::nLeft = nCol
::nBottom = nRow + nHeight - 1
::nRight = nCol + nWidth - 1
::nStyle = nOr( WS_VISIBLE, WS_CHILD )
::oWnd = oWnd
::nMinPage = nMinPage
::nMaxPage = nMaxPage
::nViewWidth = nViewWidth
::nViewHeight = nViewHeight
::nId = ::GetNewId()
::bPainted = bPaint
::lDrag = .f.
::lCaptured = .f.
if ! lRegistered
::Register( nOr( CS_VREDRAW, CS_HREDRAW, CS_GLOBALCLASS ) )
lRegistered = .t.
endif
::SetColor( nClrFore, nClrBack )
if ::oWnd:lVisible
::Create()
oWnd:AddControl( Self )
else
oWnd:DefControl( Self )
endif
return SELF
//----------------------------------------------------------------------------//
METHOD ReDefine( bPaint, nMinPage, nMaxPage, nViewWidth, nViewHeight,;
nId, oWnd, nClrFore, nClrBack ) CLASS TCardPreview
DEFAULT nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
nClrBack := GetSysColor( COLOR_WINDOW )
::nId = nId
::oWnd = oWnd
::nMinPage = nMinPage
::nMaxPage = nMaxPage
::nViewWidth = nViewWidth
::nViewHeight = nViewHeight
::bPainted = bPaint
if ! lRegistered
::Register( nOr( CS_VREDRAW, CS_HREDRAW, CS_GLOBALCLASS ) )
lRegistered = .t.
endif
::SetColor( nClrFore, nClrBack )
oWnd:DefControl( Self )
return SELF
//----------------------------------------------------------------------------//
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TCardPreview
if nMsg == WM_PAINT
::BeginPaint()
::Paint()
::EndPaint()
return 0
endif
return Super:HandleEvent( nMsg, nWParam, nLParam )
//----------------------------------------------------------------------------//
METHOD Paint() CLASS TCardPreview
local oRect := ::GetRect()
SetMapMode( ::hDC, MM_ANISOTROPIC )
SetWindowExt( ::hDC, ::nViewWidth, ::nViewHeight )
SetViewportExt( ::hDC, oRect:nRight, oRect:nBottom )
if ::bPainted != nil
Eval( ::bPainted, Self )
endif
return nil
//----------------------------------------------------------------------------//
I hope YOU enjoy with it.
For a sample I correct the msgcalc of Gadaleta and I insert my
Tcardpreview class as a small printer preview paper
look it please