Главная страница | назад





Article #16667: Setting printer orientation dynamically

 Question and Answer Database

FAQ1667C.txt   Setting printer orientation dynamically
Category   :Windows API
Platform    :All
Product    :C++Builder  1.x

Question:

I would like to be able to set the "Landscape" or "Portrait" of
the default printer dynamically in my program (not doing it 
manually in the Printer Setup Dialog). Is it possible? I cannot
find any API function for that.

Answer:

Under 32 bit Windows you:

1) OpenPrinter to get a handle to the printer

2) Call DocumentProperties() to get the DEVMODE for the printer.

3) Set the dmOrintation field of the DEVMODE structure

4) Call DocumentProperties(0 to set the DEVMODE for the printer.

5) Create a DC from the DEVMODE returned by step 4.

6) Use that DC to do your printing.

7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99