- HDC hDC;
- LPDEVMODE lpDevMode = NULL;
- LPDEVNAMES lpDevNames;
- LPSTR lpszDriverName;
- LPSTR lpszDeviceName;
- LPSTR lpszPortName;
-
- PRINTDLG pd;
- // __GNUWIN32__ has trouble believing PRINTDLG is 66 bytes - thinks it is 68
-#ifdef __GNUWIN32__
- pd.lStructSize = 66; // sizeof(PRINTDLG);
-#else
- pd.lStructSize = sizeof(PRINTDLG);
-#endif
- pd.hwndOwner = (HWND)NULL;
- pd.hDevMode = NULL; // Will be created by PrintDlg
- pd.hDevNames = NULL; // Ditto
- pd.Flags = PD_RETURNDEFAULT;
- pd.nCopies = 1;
-
- if (!PrintDlg((LPPRINTDLG)&pd))
- {
- if ( pd.hDevMode )
- GlobalFree(pd.hDevMode);
- if (pd.hDevNames)
- GlobalFree(pd.hDevNames);
-
- return(0);
- }
-
- if (!pd.hDevNames)
- {
- if ( pd.hDevMode )
- GlobalFree(pd.hDevMode);
- }
-
- lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
- lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
- lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
- lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
- GlobalUnlock(pd.hDevNames);
-
- if ( pd.hDevMode )
- {
- lpDevMode = (DEVMODE*) GlobalLock(pd.hDevMode);
- lpDevMode->dmOrientation = orientation;
- lpDevMode->dmFields |= DM_ORIENTATION;
- }