In one of my apps I offer the user the ability to change the source tray used when printing. This is straight-forward enough - you modify the dmDefaultSource
member of the DEVMODE
structure, call ResetDC
and all is well.
However, I now want to use the default source tray as set on the printer's control panel (ignoring whatever the default has been set to via the driver in the Windows Printers and Faxes folder). I assumed this would be easy - specify DMBIN_AUTO
as the default source. No such luck - when I do this the printers I have tested with all use Tray 1.
So, I tried DMBIN_FORMSOURCE
instead (which actually corresponds to the Auto Select
option when you enumerate the source trays via DeviceCapabilities/DC_BINNAMES
) but had the same problem.
So then I decided to try something a bit different - and removed the DM_DEFAULTSOURCE
bit from the dmFields
of DEVMODE
before calling ResetDC
and hey, it works and the document is printed from the source tray as set on the printer itself.
LPDEVMODE devMode = reinterpret_cast<LPDEVMODE>(GlobalLock(devModeHandle));
devMode->dmFields &= ~DM_DEFAULTSOURCE;
ResetDC(dc, devMode);
However, this makes me nervous as I have only tried it with a couple of different printer models and am worried it won't be honoured by other drivers.
Does this seem like a reasonable hack or is there a better way to print using the default printer source tray?