Ron Allen
9/27/2004 1:10:00 PM
JZ,
GetHardMargins is just used to return the hard printer margins so you
can correctly offset your drawing area. You can get the vertical drawing
height by subtracting the top margin from the bottom one and get the width
in the same way.
Now you will have to organize your drawing to do only parts or just draw
the whole drawing on the first page after translating -left, -top to get
offsets correct and then on the second page do a translate
by -left, -(bottom - top) and then draw the whole thing again. This should
get the two parts shown correctly as the items outside the page boundaries
will be ignored.
Ron Allen
"JZ" <jj@anon.anon.com> wrote in message
news:4157db6c$0$20244$cc9e4d1f@news-text.dial.pipex.com...
> Hi,
>
> I''ve found the GetHardMargins code written by Ron Allen.
> I have it working...
>
> But I''ve not exactly sure what to do with it.
>
> I simple want to paint a drawing over 2 pages.
> The 2 bits of paper would then be trimmed and stuck together with tape.
>
> I think the easiest thing for me to do is do derive a number which will
> all
> me to pass in an offset into my drawing function.
>
> Any suggestions how I can do this?
>
> --
> JZ
>
> Heres the code I''ve got...
> Dim lLeft As Single
>
> Dim lTop As Single
>
> Dim lRight As Single
>
> Dim lBottom As Single
>
> Dim hdcPtr As IntPtr
>
> Dim gr As Graphics =
> PrintDocument1.PrinterSettings.CreateMeasurementGraphics()
>
> hdcPtr = gr.GetHdc
>
> GetHardMargins(hdcPtr, lLeft, lTop, lRight, lBottom)
>
> gr.ReleaseHdc(hdcPtr)
>
> Private Declare Function GetDeviceCaps Lib "gdi32.dll" (ByVal hdc As
> IntPtr,
> ByVal nIndex As Int32) As Int32
>
> Private Sub GetHardMargins(ByVal hDC As IntPtr, ByRef Left As Single,
> ByRef
> Top As Single, ByRef Right As Single, ByRef Bottom As Single)
>
>
>
> Const PHYSICALOFFSETX As Int32 = 112
>
> Const PHYSICALOFFSETY As Int32 = 113
>
> Const HORZRES As Int32 = 8
>
> Const VERTRES As Int32 = 10
>
> Const HORZSIZE As Int32 = 4
>
> Const VERTSIZE As Int32 = 6
>
> Dim offx As Single = Convert.ToSingle(GetDeviceCaps(hDC, PHYSICALOFFSETX))
>
> Dim offy As Single = Convert.ToSingle(GetDeviceCaps(hDC, PHYSICALOFFSETY))
>
> Dim resx As Single = Convert.ToSingle(GetDeviceCaps(hDC, HORZRES))
>
> Dim resy As Single = Convert.ToSingle(GetDeviceCaps(hDC, VERTRES))
>
> Dim hsz As Single = Convert.ToSingle(GetDeviceCaps(hDC, HORZSIZE)) / 25.4F
> ''
> Screen width in inches.
>
> Dim vsz As Single = Convert.ToSingle(GetDeviceCaps(hDC, VERTSIZE)) / 25.4F
> ''
> Screen height in inches.
>
> Dim ppix As Single = resx / hsz
>
> Dim ppiy As Single = resy / vsz
>
> Left = (offx / ppix) * 100.0F
>
> Top = (offy / ppix) * 100.0F
>
> Bottom = Top + (vsz * 100.0F)
>
> Right = Left + (hsz * 100.0F)
>
> End Sub
>
>