C
charles hamm
I'm trying to use PrintDlg (and PRINTDLG) to create a printer dialog
with landscape as the default. Here is my code (from within a
CDialog-based class):
PRINTDLG printDlg;
ZeroMemory(&printDlg, sizeof(printDlg));
printDlg.lStructSize = sizeof(printDlg);
printDlg.Flags = PD_RETURNDEFAULT;
PrintDlg(&printDlg);
DEVMODE* pDevMode = (DEVMODE*)printDlg.hDevMode;
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
printDlg.hwndOwner = m_hWnd;
printDlg.Flags = PD_RETURNDC | PD_NOSELECTION;
if (PrintDlg(&printDlg)) {
The problem is that the HANDLE returned in hDevMode from the first
call to PrintDlg does not point to anything that looks like a DEVMODE
structure. Furthermore, if I set the dmOrientation field to landscape,
the print box comes up with orientation set to portrait. What am I
doing wrong here? Is a HANDLE not just a disguised pointer? The
PRINTDLG documentation implies that this should work.
with landscape as the default. Here is my code (from within a
CDialog-based class):
PRINTDLG printDlg;
ZeroMemory(&printDlg, sizeof(printDlg));
printDlg.lStructSize = sizeof(printDlg);
printDlg.Flags = PD_RETURNDEFAULT;
PrintDlg(&printDlg);
DEVMODE* pDevMode = (DEVMODE*)printDlg.hDevMode;
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
printDlg.hwndOwner = m_hWnd;
printDlg.Flags = PD_RETURNDC | PD_NOSELECTION;
if (PrintDlg(&printDlg)) {
The problem is that the HANDLE returned in hDevMode from the first
call to PrintDlg does not point to anything that looks like a DEVMODE
structure. Furthermore, if I set the dmOrientation field to landscape,
the print box comes up with orientation set to portrait. What am I
doing wrong here? Is a HANDLE not just a disguised pointer? The
PRINTDLG documentation implies that this should work.