+bool wxPrinterDC::StartDoc(const wxString& message)
+{
+ DOCINFO docinfo;
+ docinfo.cbSize = sizeof(DOCINFO);
+ docinfo.lpszDocName = (const wxChar*)message;
+
+ wxString filename(m_printData.GetFilename());
+
+ if (filename.IsEmpty())
+ docinfo.lpszOutput = NULL;
+ else
+ docinfo.lpszOutput = (const wxChar *) filename;
+
+#if defined(__WIN95__)
+ docinfo.lpszDatatype = NULL;
+ docinfo.fwType = 0;
+#endif
+
+ if (!m_hDC)
+ return FALSE;
+
+ int ret =
+#ifndef __WIN32__
+ ::StartDoc((HDC) m_hDC, &docinfo);
+#else
+#ifdef UNICODE
+ ::StartDocW((HDC) m_hDC, &docinfo);
+#else
+#ifdef __TWIN32__
+ ::StartDoc((HDC) m_hDC, &docinfo);
+#else
+ ::StartDocA((HDC) m_hDC, &docinfo);
+#endif
+#endif
+#endif
+
+#ifndef __WIN16__
+ if (ret <= 0)
+ {
+ DWORD lastError = GetLastError();
+ wxLogDebug(wxT("wxDC::StartDoc failed with error: %d\n"), lastError);
+ }
+#endif
+
+ return (ret > 0);
+}
+
+void wxPrinterDC::EndDoc(void)
+{
+ if (m_hDC) ::EndDoc((HDC) m_hDC);
+}
+
+void wxPrinterDC::StartPage(void)
+{
+ if (m_hDC)
+ ::StartPage((HDC) m_hDC);
+}
+
+void wxPrinterDC::EndPage(void)
+{
+ 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;
+
+ deviceName = lpszDeviceName;
+ portName = lpszPortName;
+
+ GlobalUnlock(pd.hDevNames);
+ GlobalFree(pd.hDevNames);
+ pd.hDevNames=NULL;
+ }
+
+ if (pd.hDevMode)
+ {
+ GlobalFree(pd.hDevMode);
+ pd.hDevMode=NULL;
+ }
+ return ( deviceName != wxT("") );
+}
+
+#if 0
+// This uses defaults, except for orientation, so we should eliminate this function
+// and use the 2nd form (passing wxPrintData) instead.