I don't know what "#VPE.Device := #gb_printr" exactly means in your programming language, but I assume it means "selected a printer".
Well, first of all all, you can only set the Duplex Mode for printers which support duplex printing. Otherwise the command is without effect.
Second, when you select a different printer, its default settings are initialized. So you are right: after selecting a different printer device, you must set the Duplex Mode again.
How can I set duplex printing (which I need to control odd and even pages/breaks) before the user clicks on the printer icon in the VPE preview?
The easiest would be to set the Duplex Mode after you specify the device.
Example:
- Code: Select all
Vpe.OpenDoc
Vpe.Device = "Printer Xyz"
Vpe.DevDuplex = VDUP_VERTICAL
If you wish to specify the Duplex Mode immediately when the user clicks onto the print-button in the VPE Preview window, you can handle the event RequestPrint(), which is sent by VPE after the user clicked onto the print button - and it is sent during different stages of the printer setup process.
In you case you should handle the RequestPrint() event either for PRINT_MSG_SETUPSTART, which allows you to pre-initialize device properties (like the Duplex Mode) before the printer setup dialog is shown.
Or - if you want to assure that the user does not deselect the Duplex Mode - handle PRINT_MSG_SETUPEND, which is sent after the printer setup dialog has been closed.
More details about events and the RequestPrint() event can be found in the help files.