farcuri
asked on
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->PrintDia log1->Exec ute();
frmBurnInResults->Print();
frmBurnInResults->PrintDia
frmBurnInResults->Print();
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.
frmBurnInResults->Print();
statement.
ASKER
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?
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?
ASKER
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
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
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.
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.
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I didn't implement this solution. Thanks for your expertise.
I'm also curious, did you find another way to do this?
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.