Page 2 of 2

Re: Report Margins

PostPosted: Mon Jan 01, 2018 11:31 am
by Enrico Maria Giordano
ukoenig wrote:I tested changing the STYLE expecting maybe to show lines dotted
but there are only solid lines, COLOR works

DEFINE PEN oPen[1] STYLE 0 WIDTH 3 COLOR CLR_RED
DEFINE PEN oPen[2] STYLE 1 WIDTH 2 COLOR CLR_BLUE

regards
Uwe :?:


https://msdn.microsoft.com/it-it/library/windows/desktop/dd183509(v=vs.85).aspx

Please note: "This style is valid only when the pen width is one or less in device units."

/* Pen Styles */
#define PS_SOLID 0
#define PS_DASH 1 /* ------- */
#define PS_DOT 2 /* ....... */
#define PS_DASHDOT 3 /* _._._._ */
#define PS_DASHDOTDOT 4 /* _.._.._ */
#define PS_NULL 5
#define PS_INSIDEFRAME 6
#define PS_USERSTYLE 7
#define PS_ALTERNATE 8

EMG

Re: Report Margins

PostPosted: Mon Jan 01, 2018 12:20 pm
by Otto
Hello Silvio,
please try to use EasyReport.

POP is the Keyword.
POP = PRINTAREA on PRINTAREA .

Best regards,
Otto

Re: Report Margins

PostPosted: Mon Jan 01, 2018 6:30 pm
by Silvio.Falconi
I'm making label print function and my labels are on 0,0 (x,y) no respect margins. I use oprinter device
I no use ER I use that my app I saw you at sillian

but this afternoon perhaps I found a solution

oPrinter := TPrinter():New( ...... )

nLogPixX := oPrinter:nLogPixelX() / 2.54 ( centimetres)
nLogPixY := oPrinter:nLogPixelY() / 2.54

nLeftMargin := Int( nLogPixX * 0.5 )
nRightMargin := Int( nLogPixX * 0.5 )
nTopMargin := Int( nLogPixY * 0.5 )
nDnMargin := Int( nLogPixY * 0.5 )


now respect top and left margin

Re: Report Margins

PostPosted: Mon Jan 01, 2018 11:15 pm
by Silvio.Falconi
i EXPLAIN YOU

Please compile this test
Code: Select all  Expand view


#include <fivewin.ch>
#define PAD_LEFT            0
#define PAD_RIGHT           1
#define PAD_CENTER          2

Function Test(lPreview)
LOCAL oPrinter
Local nLogPixX,nLogPixY
Local nLeftMargin,nRightMargin,nTopMargin,nDnMargin
Local nSpaceH,nSpaceV

LOCAL hPen
local x:=0
Local y:=0

DEFAULT lPreview := .T.

 oPrinter := TPrinter():New( "Test margins", .f., lPreview  )

   nLogPixX := oPrinter:nLogPixelX() /  2.54
   nLogPixY := oPrinter:nLogPixelY() / 2.54

   nLeftMargin  := Int( nLogPixX * 0.5 )
   nRightMargin := Int( nLogPixX * 0.5 )
   nTopMargin   := Int( nLogPixY * 0.5 )
   nDnMargin    := Int( nLogPixY * 0.5 )

   nSpaceH      := Int( nLogPixY * 0.5 )
   nSpaceV      := Int( nLogPixY * 0.5 )

   //hPen :=  CreatePen( PS_DOT, 1, CLR_BLUE )
   DEFINE PEN oPen WIDTH  2   OF oPrinter STYLE PS_DOT
   DEFINE FONT oFont NAME "Arial" SIZE 0, -10 BOLD OF oPrinter
   oPrinter:StartPage()

         nLinI := 0.5
         nColI := 0.5
         nLinF := 27.4
         nColF := 20.8

         oPrinter:Cmtr2Pix(@nLinI, @nColI)
         oPrinter:cmtr2Pix(@nLinF, @nColF)
         oPrinter:Box(nLinI, nColI, nLinF, nColF, oPen  )


 oPrinter:EndPage()



if lPreview
      oPrinter:lPrvModal := .T.
      oPrinter:Preview()
   else
      oPrinter:End()
   endif


return ni


Image

on this test I try with these parameters :

nLinI := 0.5 -----> ( 0.0) + topmargin
nColI := 0.5 -----> ( 0.0) +leftmargins
nLinF := 27.4 -----> (27.9 -bottommargins)
nColF := 20.8 -----> (21.3 - rightmargins)


But How I can found these parameters from Device (oPrinter) directly ?


I try with :

nLinI := 0.5
nColI := 0.5
nLinF := oPrinter:nVertSize() / 10 - 0.5
nColF := oPrinter:nHorzSize() / 10 - 0.5

but this is right ???

Re: Report Margins

PostPosted: Mon Jan 01, 2018 11:35 pm
by Silvio.Falconi
Another test :

I set the margins :

nDnMargin := 1.5
nTopMargin := 1.5
nLeftMargin := 0.9
nRightMargin := 2.0


Code: Select all  Expand view


#include <fivewin.ch>
#define PAD_LEFT            0
#define PAD_RIGHT           1
#define PAD_CENTER          2

Function Test(lPreview)
LOCAL oPrinter
Local nLogPixX,nLogPixY
Local nLeftMargin,nRightMargin,nTopMargin,nDnMargin
Local nSpaceH,nSpaceV

LOCAL hPen


DEFAULT lPreview := .T.

 oPrinter := TPrinter():New( "Test margins", .f., lPreview  )

    nDnMargin       := 1.5
    nTopMargin      := 1.5
    nLeftMargin     := 0.9
    nRightMargin    := 2.0

   //hPen :=  CreatePen( PS_DOT, 1, CLR_BLUE )

   DEFINE PEN oPen WIDTH  2   OF oPrinter STYLE PS_DOT
   DEFINE FONT oFont NAME "Arial" SIZE 0, -10 BOLD OF oPrinter

   oPrinter:StartPage()

         nLinI := 0.5     + nTopMargin
         nColI := 0.5     + nLeftMargin
         nLinF := oPrinter:nVertSize()  / 10  - 0.5 - nDnMargin
         nColF := oPrinter:nHorzSize()  / 10  - 0.5 - nRightMargin

         oPrinter:Cmtr2Pix(@nLinI, @nColI)
         oPrinter:cmtr2Pix(@nLinF, @nColF)
         oPrinter:Box(nLinI, nColI, nLinF, nColF, oPen  )
         oPrinter:EndPage()

   if lPreview
      oPrinter:lPrvModal := .T.
      oPrinter:Preview()
   else
      oPrinter:End()
   endif


return ni

Re: Report Margins

PostPosted: Tue Jan 02, 2018 9:03 am
by Enrico Maria Giordano
That is the right way. As I already said, TPrinter has no margins to set.

EMG

Re: Report Margins

PostPosted: Tue Jan 02, 2018 5:24 pm
by Silvio.Falconi
Enrico Maria Giordano wrote:That is the right way. As I already said, TPrinter has no margins to set.

EMG


i think it can be made directly on tmetafile

Re: Report Margins

PostPosted: Tue Jan 02, 2018 6:19 pm
by Enrico Maria Giordano
Yes, it can be done. Try using

Code: Select all  Expand view
oMeta:SetOrg(nX,nY)


EMG

Re: Report Margins

PostPosted: Tue Jan 02, 2018 11:56 pm
by Silvio.Falconi
How?

Re: Report Margins

PostPosted: Wed Jan 03, 2018 10:01 am
by Silvio.Falconi
Perhaps

New method and data

::nPrnXOffset := oPrev:oDevice:nXOffset
::nPrnYOffset := oPrev:oDevice:nYOffset
::nPageWidth := oPrev:nHorzRes
::nPageHeight := oPrev:nVertRes

Method Margins class Tpreview
LOCAL nleft,ntop,nbottom,nright

nleft :=-::nPrnXOffset
ntop :=-::nPrnYOffset
nRight := ::nPageWidth - ::nPrnXOffset
nBottom := ::nPageHeight- ::nPrnYOffset

Rectangle( ::hDC, -::nPrnYOffset ,-::nPrnXOffset,::nPageHeight- ::nPrnYOffset,;
::nPageWidth - ::nPrnXOffset) , ::open:hpen)

only a test.... I not try