Dear All ,
I need help to create simple app to print the Mailing labels on A4 size paper, the number of labels per page would be 8x3=24 lables. May I request to all to provide code. Thanks in advance...!
Thanks
Shridhar
// Generating mailing labels - using FiveWin Report Preview
#include "fivewin.ch"
//----------------------------------------------------------------------------//
Function Main()
local oWnd
SET _3DLOOK ON
DEFINE WINDOW oWnd TITLE "Labels generation & preview with FiveWin"
@ 2, 2 BUTTON "&Labels" SIZE 120, 25 OF oWnd ACTION GenerateLabels()
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
function GenerateLabels()
LOCAL oPrinter, oFont
LOCAL nWidth ,; // label Width
nHeight ,; // label height
nMargin ,; // Printing margin (.2 inches)
nLblWid ,; // # labels width (2)
nLblHei // # labels height (6)
LOCAL nCounter ,; // counter of lbl on each page
nRow ,; // current row
nCol ,; // current col
nOldRow // old row position
USE customer alias "TEST"
PRINTER oPrinter FROM PREVIEW NAME "Fivewin Label Demo"
DEFINE FONT oFont NAME "ARIAL" SIZE 60,120
nLblWid := 3
nLblHei := 8
nWidth := oPrinter:nHorzRes()/nLblWid
nHeight := oPrinter:nVertRes()/nLblHei
nMargin := Int(oPrinter:nLogPixelX()*0.2)
nCounter := 0
CursorWait()
DO WHILE !Test->(Eof())
IF nCounter == 0
nRow := nMargin
nCol := nMargin
oPrinter:StartPage()
ENDIF
nOldRow := nRow
oPrinter:Box( nRow, nCol, nOldRow + nHeight - 20, nCol + nWidth - 50 )
oPrinter:SayBitmap( nRow + nHeight - 300, nCol + nWidth - 400,;
"..\bitmaps\Fw.bmp", 300, 200 )
oPrinter:Say( nRow + 15, nCol + 15, Trim( Test->First ) + " " + Test->Last, oFont )
nRow += oFont:nHeight
oPrinter:Say( nRow + 15, nCol + 15, Test->Street, oFont )
nRow += oFont:nHeight
oPrinter:Say( nRow + 15, nCol + 15, Test->City, oFont )
nRow += oFont:nHeight
oPrinter:Say( nRow + 15, nCol + 15, Test->State, oFont )
nRow += oFont:nHeight
oPrinter:Say( nRow + 15, nCol + 15, Test->Zip, oFont )
nRow := nOldRow + nHeight
Test->(DbSkip())
IF nCounter > 0 .AND. nCounter%nLblHei == 0
nRow := nMargin
nCol += nWidth
ENDIF
IF nCounter == (nLblHei*nLblWid) .AND. !Test->(Eof())
nCounter := 0
oPrinter:EndPage()
ELSE
nCounter++
ENDIF
ENDDO
CursorArrow()
oPrinter:EndPage()
oPrinter:Preview()
RELEASE FONT oFont
CLOSE TEST
RETURN (NIL)
Application
===========
Path and name: C:\VIMDEV32\DEV32\FWH32_1912\samples\label.exe (32 bits)
Size: 4,149,760 bytes
Compiler version: Harbour 3.2.0dev (r1904111533)
FiveWin version: FWH 19.12
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 8 secs
Error occurred at: 07/22/23, 20:03:00
Error description: Error BASE/1003 Variable does not exist: FIRST
Stack Calls
===========
Called from: label.prg => GENERATELABELS( 68 )
Called from: label.prg => (b)MAIN( 15 )
Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK( 179 )
Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT( 1755 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => SENDMESSAGE( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND( 1149 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1097 )
Called from: label.prg => MAIN( 17 )
System
======
CPU type: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz 3392 Mhz
Hardware memory: 16254 megs
Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %
Windows total applications running: 4
1 ,
2 , C:\VIMDEV32\DEV32\FWH32_1912\samples\label.exe
3 , C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_a8625c
4 GDI+ Window (label.exe), C:\WINDOWS\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.19041.2251_none_d9513b1fe1046f
Variables in use
================
Procedure Type Value
==========================
GENERATELABELS
Param 1: O Class: ERROR
(b)MAIN
Local 1: O Class: TPRINTER
Local 2: O Class: TFONT
Local 3: N 2480.50
Local 4: N 1169.33
Local 5: N 120
Local 6: N 2
Local 7: N 6
Local 8: N 0
Local 9: N 120
Local 10: N 120
Local 11: N 120
Local 12: S
Local 13: O Class: TPRINTER
Local 14: N 135
Local 15: N 135
Local 16: S
Local 17: U
Local 18: U
Local 19: U
Local 20: U
TBUTTON:CLICK
Param 1: O Class: TBUTTON
TBUTTON:HANDLEEVENT
_FWH
Param 1: N 2048
Param 2: N 0
Param 3: N 0
Local 1: U
SENDMESSAGE
Param 1: N 0
Param 2: N 2048
Param 3: N 0
Param 4: N 0
Param 5: N 2
Local 1: O Class: TBUTTON
TWINDOW:COMMAND
Param 1: N 2754292
Param 2: N 2048
Param 3: N 0
Param 4: N 0
TWINDOW:HANDLEEVENT
Param 1: N 101
Param 2: N 2754292
Local 1: N 0
Local 2: N 101
Local 3: N 2754292
Local 4: U
_FWH
Param 1: N 273
Param 2: N 101
Param 3: N 2754292
WINRUN
Param 1: N 2754292
Param 2: N 273
Param 3: N 101
Param 4: N 2754292
Param 5: N 1
Local 1: O Class: TWINDOW
TWINDOW:ACTIVATE
Param 1: N 2492068
MAIN
Param 1: C "NORMAL"
Param 2: U
Param 3: U
Param 4: U
Param 5: U
Param 6: U
Param 7: U
Param 8: U
Param 9: U
Param 10: U
Param 11: U
Param 12: U
Param 13: U
Param 14: U
Param 15: U
Param 16: U
Param 17: U
Param 18: U
Param 19: U
Param 20: L .F.
Local 1: O Class: TWINDOW
Local 2: U
Local 3: U
Linked RDDs
===========
DBF
DBFFPT
DBFBLOB
DBFNTX
DataBases in use
================
1: => TEST RddName: DBFNTX
==============================
RecNo RecCount BOF EOF
1 2 .F. .F.
Indexes in use TagName
Relations in use
Classes in use:
===============
1 ERROR
2 HBCLASS
3 HBOBJECT
4 TWINDOW
5 TBRUSH
6 TFONT
7 TREG32
8 TCONTROL
9 TBUTTON
10 TRECT
11 TPRINTER
12 TSTRUCT
Memory Analysis
===============
583 Static variables
Dynamic memory consume:
Actual Value: 786432 bytes
Highest Value: 786432 bytes
// Generating mailing labels - using FiveWin Report Preview
#include "fivewin.ch"
FUNCTION Main()
LOCAL oWnd
SET _3DLOOK ON
SkinButtons()
DEFINE WINDOW oWnd TITLE "Labels generation & preview with FiveWin"
@ 2, 2 BUTTON "&Labels" SIZE 120, 25 OF oWnd ACTION GenerateLabels()
ACTIVATE WINDOW oWnd
RETURN NIL
FUNCTION GenerateLabels()
LOCAL oPrinter, oFont, cAlias
LOCAL nWidth ,; // label Width
nHeight ,; // label height
nMargin ,; // Printing margin (.2 inches)
nLblWid ,; // # labels width (2)
nLblHei // # labels height (6)
LOCAL nCounter ,; // counter of lbl on each page
nRow ,; // current row
nCol ,; // current col
nOldRow // old row position
USE CUSTOMER ALIAS CUSTOMER
GO TOP
cAlias := ALIAS()
PRINTER oPrinter FROM USER PREVIEW NAME "Fivewin Label Demo"
// DEFINE FONT oFont FROM USER OF oPrinter
DEFINE FONT oFont NAME "Courier New" SIZE 0, -10 OF oPrinter
nLblWid := 2
nLblHei := 6
nWidth := oPrinter:nHorzRes()/nLblWid
nHeight := oPrinter:nVertRes()/nLblHei
nMargin := Int(oPrinter:nLogPixelX()*0.2)
nCounter := 0
CursorWait()
WHILE .NOT. ( cAlias )->( Eof() )
SYSREFRESH()
IF nCounter == 0
nRow := nMargin
nCol := nMargin
oPrinter:StartPage()
ENDIF
nOldRow := nRow
oPrinter:Box( nRow, nCol, nOldRow + nHeight - 20, nCol + nWidth - 50 )
oPrinter:SayBitmap( nRow + nHeight - 300, nCol + nWidth - 400, ;
"..\bitmaps\Fw.bmp", 300, 200 )
oPrinter:Say( nRow + 15, nCol + 15, Trim( ( cAlias )->First ) ;
+ " " + ( cAlias )->Last, oFont )
nRow += oFont:nHeight
oPrinter:Say( nRow + 15, nCol + 15, ( cAlias )->Street, oFont )
nRow += oFont:nHeight
oPrinter:Say( nRow + 15, nCol + 15, ( cAlias )->City, oFont )
nRow += oFont:nHeight
oPrinter:Say( nRow + 15, nCol + 15, ( cAlias )->State, oFont )
nRow += oFont:nHeight
oPrinter:Say( nRow + 15, nCol + 15, ( cAlias )->Zip, oFont )
nRow := nOldRow + nHeight
( cAlias )->(DbSkip())
IF nCounter > 0 .AND. nCounter%nLblHei == 0
nRow := nMargin
nCol += nWidth
ENDIF
IF nCounter == ( nLblHei*nLblWid ) .AND. .NOT. ( cAlias )->( Eof() )
nCounter := 0
oPrinter:EndPage()
ELSE
nCounter++
ENDIF
ENDDO
CursorArrow()
oPrinter:EndPage()
oPrinter:Preview()
RELEASE FONT oFont
CLOSE( cAlias )
RETURN NIL
// FIN / END
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 54 guests