Could someone explain to me how to implement oPrn:nYoffset and oPrn:nXoffset in a print with a practical example?
what is the purpose of oPrn:nYoffset and oPrn:nXoffset ?
Otto wrote:nXoffset and nYoffset are only used in the methods:
New - Sets nXoffset and nYoffset based on printer settings.
Cmtr2Pix - Uses nXoffset and nYoffset to convert centimeters to pixels.
Mmtr2Pix - Uses nXoffset and nYoffset to convert millimeters to pixels.
Inch2Pix - Uses nXoffset and nYoffset to convert inches to pixels.
CmRect2Pix - Uses nXoffset and nYoffset to convert a rectangle from centimeters to pixels.
Pix2Mmtr - Uses nXoffset and nYoffset in the comment, but not directly in the code.
Pix2Inch - Uses nXoffset and nYoffset in the comment, but not directly in the code.
// Set the X and Y offsets for printing
oPrn:nXoffset := 10; // Set X offset to 10 units
oPrn:nYoffset := 20; // Set Y offset to 20 units
// Now, when you print something, it will start from the offset position
These methods use nXoffset and nYoffset to convert units of measurement and adjust the print position on the page.
#include "fivewin.ch"
Function test()
local oPrn
local cDescRep := "Trying xoffset and yOffset"
local aPrn := GetPrinters()
//-------------------------------------------------------//
local nWidth := 20 +0.2
local nHeight := 7.80 +0.5
local nGutter := 0.5
local nRows := 3
local nCols := 1
local nPrintHeight := nRows * ( nHeight + nGutter ) - nGutter
local nPrintWidth := nCols * ( nWidth + nGutter ) - nGutter
local nTopMargin := 0
local nLeftMargin := 0
local nTop := nTopMargin
local nLeft := nLeftMargin
local nPageH := 29.7 //A4
local nPageW := 21
//-------------------------------------------------------//
IF nTopMargin= 0
nTopMargin := ( nPageH - nPrintHeight ) / 2
nLeftMargin := ( nPageW - nPrintWidth ) / 2
ENDIF
nTop := nTopMargin
nLeft := nLeftMargin
xbrowser aPrn
oPrn:=PrintBegin(cDescRep,.F.,.t.,,.T.)
? oPrn:nYoffset,oPrn:nXoffset // give me 94,94
* oPrn:nYoffset :=0
* oPrn:nXoffset :=0
PageBegin()
//first Box
PrintBox(nTop, nLeft, nWidth, nHeight,0,0,20,1.2,oPrn)
//second Box
PrintBox(nTop, nLeft, nWidth, nHeight,1.2,0,20,7.8,oPrn)
PageEnd()
PrintEnd()
return nil
//---------------------------------------------------------------------//
Function PrintBox(nRow, nCol, nWidth, nHeight,nX,nY,nLar,nAlt,oPrn)
local oFnt
local cFontname:= "Arial"
local nFontSize:= 12
local lBold:= .f.
local lItalic:= .f.
local X,Y,Z,K
local lBordo:= .t.
local nColorBordo:= CLR_BLACK
local nSizeBordo:=0.01
local nBackcolor :=CLR_WHITE
local cText:=""
local nColorFont:= CLR_BLACK
local nAlignOriz:= 1
local nAlignVert:= 1
local cUnit:= "CM"
nRow += 0.2
nCol += 0.2
nWidth -= 0.4
nHeight -= 0.4
x:= nRow+nX
y:= nCol+nY
z:= x+nAlt
k:= y+nLar
//--------------------------------------------------------------------------//
oFnt:=TFont():New(cFontName ,0,-nFontSize,.F.,lBold ,,,,lItalic,,,,,,,oPrn)
IF lBordo
oPrn:Box(X, Y, Z, K,;
{ nColorBordo, (nSizeBordo) }, nBackcolor, ;
{cText, oFnt, nColorFont, "TL" }, ;
cUnit )
else
oPrn:Box(X, Y, Z, K,;
{ CLR_WHITE, 1 }, CLR_WHITE, ;
{cText, oFnt, nColorFont, "TL" }, ;
cUnit )
endif
oFnt:end()
//----------------------------------------------------------------------------//
return nil
local nWidth := 20 +0.2
local nHeight := 7.80 +0.5
local nGutter := 0.5
local nRows := 3
local nCols := 1
local nPrintHeight := nRows * ( nHeight + nGutter ) - nGutter
local nPrintWidth := nCols * ( nWidth + nGutter ) - nGutter
nTopMargin := ( nPageH - nPrintHeight ) / 2
nLeftMargin := ( nPageW - nPrintWidth ) / 2
Otto wrote:Link in printer.prg and insert some msgInfo().
Try to find the differences.
Otto wrote:I do not see that method box supports: nXoffset or nYottset.
Look into printer.prg.
METHOD Box( nRow, nCol, nBottom, nRight, oPen ) INLINE ;
Rectangle( ::hDCOut, nRow, nCol, nBottom, nRight,;
If( oPen != nil, oPen:hPen, 0 ) )
METHOD Box( nTop, nLeft, nBottom, nRight, anoPen, noBrush, aText, cUnits )
if ::hDC != 0
aOffset = PrnOffset( ::hDC )
::nXOffset = aOffset[ 1 ]
::nYOffset = aOffset[ 2 ]
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 48 guests