![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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.CreateMeasurementGr aphics() 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 |
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Hi, I guess what I really need to know is how to convert the hard left margin value into something I subtract from the default drawing number format. ? -- JZ |
#6
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |