"Ron Allen" <rallen@_nospam_src-us.com> wrote in message news:%23gG56LCkEHA.484@TK2MSFTNGP10.phx.gbl...
> Gregg,
> Make sure that when you get the hDC from the printer before calling this that you release it again right away or there could be
> some problems.
> Ron Allen
> "Gregg Walker" <gregg__INVALID_ACCOUNT__@rrmca.comXNXOXSXPXAXMX> wrote in message news:eSgZMk5jEHA.3016@tk2msftngp13.phx.gbl...
>> Thank you for the quick reply Herfried. I will definitely use this for my application.
>>
>> Can I assume from your response that the problem as I described it is a bug that will be or has been fixed in .Net Framework 2.0?
>> Or is your sample just the expected way to deal with this issue?
>>
>> Thanks again.
>>
>> Sincerely,
>> Gregg Walker
>>
>> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:eLN0EY5jEHA.3144@TK2MSFTNGP10.phx.gbl...
>>>* "Gregg Walker" <gregg__INVALID_ACCOUNT__@rrmca.comXNXOXSXPXAXMX> scripsit:
>>>> Is there some other way to get the physical page bounds so that I can rescale the drawing points and rectangles?
>>>
>>> From my FAQ (<URL:
http://dotnet.mvps.org/dotnet/faqs/>):
>>>
>>> Sample is based on a C# sample written by Ron Allen.
>>>
>>> The method 'GetHardMargins' expects a hDC to the printer's 'Graphics'
>>> object during the print call. The printer may have a margin that is
>>> different from the PrintPreViewDialog's margin. Values are returned in
>>> the procedure's parameters:
>>>
>>> \\\
>>> Public Declare Function GetDeviceCaps Lib "gdi32.dll" ( _
>>> ByVal hdc As IntPtr, _
>>> ByVal nIndex As Int32 _
>>> ) As Int32
>>>
>>> Private Const PHYSICALOFFSETX As Int32 = 112
>>> Private Const PHYSICALOFFSETY As Int32 = 113
>>> Private Const HORZRES As Int32 = 8
>>> Private Const VERTRES As Int32 = 10
>>> Private Const HORZSIZE As Int32 = 4
>>> Private Const VERTSIZE As Int32 = 6
>>>
>>> Public Sub GetHardMargins( _
>>> ByVal hDC As IntPtr, _
>>> ByRef Left As Single, _
>>> ByRef Top As Single, _
>>> ByRef Right As Single, _
>>> ByRef Bottom As Single _
>>> )
>>> 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
>>> ///
>>>
>>> --
>>> M S Herfried K. Wagner
>>> M V P <URL:
http://dotnet.mvps.org/> >>> V B <URL:
http://dotnet.mvps.org/dotnet/faqs/> >>
>>
>
>