Page 1 of 1

Rpreview Margin

Posted: Wed May 14, 2008 9:36 am
by Silvio
How I can show a Dotted Lines into Rpreview Class to show the Margins of the paper ?

I made a method but it not run ok



I add this data
DATA nMargTop,nMargLeft,nMargBottom,nMargRight AS NUMERIC INIT 0
DATA lMargin, hSolidPen

and on the New method
::hSolidPen := CreatePen (PS_DOT, 1, CLR_GRAY)
::nMargTop := 15
::nMargLeft := 15
::nMargBottom := 15
::nMargRight := 15
::lMargin = .T.

and I add a new method

Code: Select all

 METHOD SMargin() CLASS Tpaper
     if !::lMargin
        return nil
     endif
     ::oWnd:GetDC()
     MoveTo( ::oWnd:hDC              ,;
          ::nMargTop   ,;
          ::nMargLeft )
     LineTo( ::oWnd:hDC              ,;
          ::nMargTop                ,;
          ::nMargLeft             ,;
           ::hSolidPen:hPen )
     MoveTo( ::oWnd:hDC              ,;
        ::nMargTop              ,;
        ::nMargRight )
     LineTo( ::oWnd:hDC              ,;
           ::nMargRight               ,;
           ::nMargBottom             ,;
           ::hSolidPen:hPen )
     ::oWnd:ReleaseDC()
return nil

and I add ::Smargin() on the PaintMeta method



Some can help me please ?

Posted: Wed May 14, 2008 12:05 pm
by James Bott
Falconi,

>I made a method but it not run ok

You are going to have to tell us what the problem is.

Is TPaper your own class?

Regards,
James

Posted: Wed May 14, 2008 11:18 pm
by Silvio
Sorry Mr James,
I renamed rpreview class to tpaper in my file to try the new method.
I wanted to show margins on rpreview if it is possible

Posted: Thu May 15, 2008 12:52 am
by James Bott
Falconi,

OK, but you still didn't tell us what the problem is.

James

Posted: Thu May 15, 2008 7:06 am
by Silvio
the problem is this
I want see Line dotted Vertical and Horizontal as Margins of the paper
It is possible make it?
where is the error on the method ?

thanks

Posted: Thu May 15, 2008 7:43 am
by James Bott
Falconi,

You still didn't tell me what the problem is. I am assuming that you are not seeing any lines?

>I renamed rpreview class to tpaper in my file to try the new method.

OK. I also assume you are using TPrinter to draw the page? If so, did you modify TPrinter to call TPaper instead of TPreview? It would actually be easier to take a copy of TPreview and modify it then link it into your test program. Then you don't need to modify TPrinter also.

Also, you are attempting to draw borders 15 pixels from the edge. I don't know of any printer that can print that close to the edge. Perhaps you need to use the real margins of the page, or at least margins that are much futher from the edge.

James

Posted: Thu May 15, 2008 8:14 am
by Silvio
I not see any lines
I want see these lines in Metafile in Rpreview window
U mustinsert all data and method into Rpreview class
then you must try test4prn.prg of sample of fwh
when you go in Preview you must see the lines as margins

I need see the real margins of paper

I not see these lines : where is the error ?

thanks

Posted: Thu May 15, 2008 8:51 am
by Antonio Linares
Silvio,

Have you tried to paint the lines in a different coordinates ?

Silvio, regarding your classes contributions, we simply had no time to review them and include them yet. We appreciate your contributions, but we have been very busy building 8.05. Thanks

Posted: Thu May 15, 2008 10:02 am
by Silvio
Antonio,
I try to draw line into different ccordinates I try also with a function
DRAWLINE

Code: Select all


  HB_FUNC( DRAWLINE )
{
   MoveToEx( (HDC) hb_parnl( 1 ), hb_parni( 2 ), hb_parni( 3 ), NULL );
   LineTo( (HDC) hb_parnl( 1 ), hb_parni( 4 ), hb_parni( 5 ) );
}


Posted: Thu May 15, 2008 10:42 am
by Antonio Linares
You have commented that you are using metafiles, right ?

Then maybe you need to paint the lines inside the metafiles, when building them

Posted: Thu May 15, 2008 11:00 am
by Silvio
I also try in Tmetafile class

and I insert it on METHOD Paint() after

if ::hMeta != 0
::shadow()
::smargins()

SetMapmode(.......

Posted: Thu May 15, 2008 11:07 am
by Silvio
and I found also this information to calculate my margins

aMargins := PageGetMargins () // in 1/100 mm

AEval( aMargins, { |x,y| aMargins[y] := x/1000 } ) // Margin in cm


? aMargins[ 1] --> 2.50
? aMargins[ 2] --> 2.50
? aMargins[ 3] --> 2.50
? aMargins[ 4] --> 2.50