I suspect that you will scale on the printable width and height of the
paper (ie,. p.Width and p.Height).
As a matter of interest, the "Computed height" presented in the snippet
of the Rb LR example below seems like a meaningless parameter for
inclusion in an example. It implies that the top and bottom margins
provided by the printer are equal, which is not generally the case.
It's convenient to think of a rectangle within a rectangle. The outer
rectangle is the paper, ie., the page, and the inner rectangle is the
maximum printable region provided by the printer for the paper
selected. The dimensions of the outer rectangle are p.PageWidth and
p.PageHeight. The dimensions of the inner rectangle are p.Width and
p.Height. The origin of the drawing area (0,0) is at the top left
corner of the inner rectangle. The inner rectangle is located within
the outer rectangle by p.PageLeft and p.PageTop, measured from the
origin of the drawing area, making both of these negative numbers.
One can place a character at the four corners of the printable area by
modifying the Rb example to the following:
Dim settings as String
Dim p as PrinterSetup
Dim g as graphics
p=New PrinterSetup
If p.PageSetupDialog Then
settings=p.SetupString
g = OpenPrinterdialog(p)
End If
staticText1.text="PageLeft="+Str(p.pageLeft)
staticText2.text="PageTop="+Str(p.pagetop)
staticText3.text="PageHeight="+Str(p.pageheight)
staticText4.text="PageWidth="+Str(p.pagewidth)
staticText5.text="Height="+Str(p.Height)
staticText6.text="Width="+Str(p.width)
staticText7.text="Computed height="+Str(p.height-2*p.pagetop)
staticText8.text="Computed width="+Str(p.width-2*p.pageleft)
If g <> nil then
g.DrawString "x", 0, p.Height //lower left limit
g.DrawString "x", p.Width - g.StringWidth("x"), p.Height //lower
right limit
g.DrawString "x", p.Width - g.StringWidth("x"), g.TextHeight()
//upper right limit
g.DrawString "x", 0, g.TextHeight() //upper left limit
g = nil
End if
Jack
On Dec 31, 2004, at 9:16 AM, Tony Alfrey wrote:
Terry Ford wrote:
On 31-Dec-04, at 6:54 AM, Tony Alfrey wrote:
I have a method that draws an elaborate graph to a canvas control.
It rescales itself for the size of the control (so it asks the width
and height of the control). I want to print the same graph. Where
do I "read" the width and height of paper selected in the
PrintDialog so that I can scale the graph to fit?
<snip>
staticText7.text="Computed height="+Str(p.height-2*p.pagetop)
staticText8.text="Computed width="+Str(p.width-2*p.pageleft)
Terry
Thanks, Terry and Barrie!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|