+ if (m_hDC)
+ ::EndPage((HDC) m_hDC);
+}
+
+// Returns default device and port names
+static bool wxGetDefaultDeviceName(wxString& deviceName, wxString& portName)
+{
+ deviceName = "";
+
+ LPDEVNAMES lpDevNames;
+ LPSTR lpszDriverName;
+ LPSTR lpszDeviceName;
+ LPSTR lpszPortName;
+
+ PRINTDLG pd;
+
+ // Cygwin 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 FALSE;
+ }
+
+ if (pd.hDevNames)
+ {
+ lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
+ lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
+ lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
+ lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
+ GlobalUnlock(pd.hDevNames);
+ GlobalFree(pd.hDevNames);
+ pd.hDevNames=NULL;
+
+ deviceName = lpszDeviceName;
+ portName = lpszPortName;
+ }
+
+ if (pd.hDevMode)
+ {
+ GlobalFree(pd.hDevMode);
+ pd.hDevMode=NULL;
+ }
+ return ( deviceName != wxT("") );