LB Booster
« Getting printer orientation? »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:02am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Getting printer orientation?  (Read 531 times)
Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx 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.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
« Last Edit: Sep 1st, 2015, 11:57am by Richard Russell » User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Getting printer orientation?
« Reply #2 on: Sep 1st, 2015, 7:20pm »

Thank you. That works perfectly grin
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls