Author |
Topic: Getting printer orientation? (Read 531 times) |
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Getting printer orientation?
« Thread started on: Sep 1st, 2015, 10:03am » |
|
Is there a straightforward way to find the current printer page orientation?
I found an old piece of code by Dennis McKinney, but it seems very long and I don't think it works any more. I also found some code to change the printer orientation, but I just need to know what it is set to.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Getting printer orientation?
« Reply #1 on: Sep 1st, 2015, 11:53am » |
|
on Sep 1st, 2015, 10:03am, Monkfish wrote:Is there a straightforward way to find the current printer page orientation?. |
|
If the page height is greater than the width then it's portrait, and if the width is greater than the height it's landscape!
Code: !hDCprt = @prthdc%
calldll #gdi32, "GetDeviceCaps", hDCprt as ulong, _HORZRES as long, width as long
calldll #gdi32, "GetDeviceCaps", hDCprt as ulong, _VERTRES as long, height as long
if height > width then
print "Portrait"
else
print "Landscape"
end if If you prefer an LB-compatible version get the printer DC using a call to the PrintDlg API with PD_RETURNDEFAULT and PD_RETURNDC flags.
Richard.
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Getting printer orientation?
« Reply #2 on: Sep 1st, 2015, 7:20pm » |
|
Thank you. That works perfectly
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Getting printer orientation?
« Reply #3 on: Sep 1st, 2015, 9:22pm » |
|
on Sep 1st, 2015, 7:20pm, Monkfish wrote:Thank you. That works perfectly ;D |
|
For completeness, here's the somewhat more complicated LB-compatible version:
Code: struct pd, lStructSize as long, hwndOwner as ulong, hDevMode as ulong, hDevNames as ulong, _
hDC as ulong, Flags as long, nFromPage as short, nToPage as short, nMinPage as short, _
nMaxPage as short, nCopies as short, hInstance as ulong, lCustData as long, _
lpfnPrintHook as long, lpfnSetupHook as long, lpPrintTemplateName as ptr, _
lpSetupTemplateName as ptr, hPrintTemplate as ulong, hSetupTemplate as ulong
pd.lStructSize.struct = len(pd.struct)
pd.Flags.struct = _PD_RETURNDEFAULT or _PD_RETURNDC
calldll #comdlg32, "PrintDlgA", pd as struct, result as long
hDCprt = pd.hDC.struct
calldll #gdi32, "GetDeviceCaps", hDCprt as ulong, _HORZRES as long, width as long
calldll #gdi32, "GetDeviceCaps", hDCprt as ulong, _VERTRES as long, height as long
if height > width then
print "Portrait"
else
print "Landscape"
end if Richard.
|
|
Logged
|
|
|
|
|