• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 522
  • Last Modified:

How do I print a form in landscape mode?

I would like to print a form in runtime with the fewest button clicks.  I need to have it print in landscape mode.  If I use the following code I can print the form but it first brings up the PrintDialog box and then the operator has to manually select landscape mode before it prints.  Is there a simple way to do this programmatically?
 frmBurnInResults->PrintDialog1->Execute();
 frmBurnInResults->Print();
0
farcuri
Asked:
farcuri
  • 4
  • 4
1 Solution
 
satsumoSoftware DeveloperCommented:
Use DocumentProperties, to get a DEVMODE structure.
Set the dmOrientation value to DMORIENT_LANDSCAPE.
Use DocumentProperties again to configure the driver.
Use the returned DEVMODE with CreateDC.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd183576(v=vs.85).aspx

If this is going to be used in a wide variety of places, you might want to set the printer settings a bit more thoroughly.  The printer could be set to the wrong paper size by default.  Also consider setting number of copies, print quality, duplex etc.
0
 
aikimarkCommented:
I don't know the C++ code to do this, but you can set the default printer object's properties prior to your print.  You should be able to set the orientation to landscape prior to your
frmBurnInResults->Print();
statement.
0
 
farcuriAuthor Commented:
Hi aikimark,
Could you be a little more specific?  What is the default printer's object properties? Is this the same as the DocumentsProperties suggested by satsumo?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
farcuriAuthor Commented:
Hi Satsumo,

thanks for your solution.  Unfortunately I don't know anything about DocumentProperties.  I will take a look at your link.  Is this a simple approach?  I'm not interested in anything too involved.  Could you give me more of an example?
That would help.
Thanks,
Fabio
0
 
satsumoSoftware DeveloperCommented:
It is simple, which is good because there isn't any other way.  That is how you configure a printer in Windows.  in earlier version the process was similar (still using a DEVMODE) but the functions were quite obscure.  At least now there is a single function with a sensible name.

The list of settings I mentioned is simply because printing is quite involved, by nature.  As long as you make sure everything is set correctly there shouldn't be any surprises.

But bear in mind, people could be print to all manner of devices.  Dot matrix printer, A4 inkjets, A3 full colour lazer printer, A0 electrostatic plotter.  If this software is going to be released widely, you might want to check printer capabilities.  Like can it do Landscape with the paper size you want.
0
 
farcuriAuthor Commented:
Hi Satsumo,

I need some time to look into this.  I   will be on vaca next week. So I might not get to it for a while.
0
 
satsumoSoftware DeveloperCommented:
That's no problem, lots of questions on EE get left hanging while asker is busy with something else.  There's often months before an answer is chosen.  You might get a mail asking you to resolve the question and experts might get notifications about the question being neglected.

You mentioned giving an example, I did write a short follow on answer, saying I could provide a part of the code if that would help.  That reply seems to have been lost, I think I browse away from the page and forget to press the Submit button sometimes.
0
 
farcuriAuthor Commented:
I didn't implement this solution.  Thanks for your expertise.
0
 
satsumoSoftware DeveloperCommented:
I'm also curious, did you find another way to do this?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now