+ m_printDialogData.SetMinPage(minPage);
+ m_printDialogData.SetMaxPage(maxPage);
+ if (fromPage != 0)
+ m_printDialogData.SetFromPage(fromPage);
+ if (toPage != 0)
+ m_printDialogData.SetToPage(toPage);
+
+ if (minPage != 0)
+ {
+ m_printDialogData.EnablePageNumbers(TRUE);
+ if (m_printDialogData.GetFromPage() < m_printDialogData.GetMinPage())
+ m_printDialogData.SetFromPage(m_printDialogData.GetMinPage());
+ else if (m_printDialogData.GetFromPage() > m_printDialogData.GetMaxPage())
+ m_printDialogData.SetFromPage(m_printDialogData.GetMaxPage());
+ if (m_printDialogData.GetToPage() > m_printDialogData.GetMaxPage())
+ m_printDialogData.SetToPage(m_printDialogData.GetMaxPage());
+ else if (m_printDialogData.GetToPage() < m_printDialogData.GetMinPage())
+ m_printDialogData.SetToPage(m_printDialogData.GetMinPage());
+ }
+ else
+ m_printDialogData.EnablePageNumbers(FALSE);
+
+ // Create a suitable device context
+ wxDC *dc = NULL;
+ if (prompt)
+ {
+ dc = PrintDialog(parent);
+ if (!dc)
+ return FALSE;
+ }
+ else
+ {
+ // dc = new wxPrinterDC("", "", "", FALSE, m_printData.GetOrientation());
+ dc = new wxPrinterDC(m_printDialogData.GetPrintData());
+ }
+
+ // May have pressed cancel.
+ if (!dc || !dc->Ok())
+ {
+ if (dc) delete dc;
+ return FALSE;
+ }
+
+ int logPPIScreenX = 0;
+ int logPPIScreenY = 0;
+ int logPPIPrinterX = 0;
+ int logPPIPrinterY = 0;
+
+ HDC hdc = ::GetDC(NULL);
+ logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
+ logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
+ ::ReleaseDC(NULL, hdc);
+
+ logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX);
+ logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY);
+ if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
+ {
+ delete dc;
+ return FALSE;
+ }
+
+ printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
+ printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
+
+ // Set printout parameters
+ printout->SetDC(dc);
+
+ int w, h;
+ dc->GetSize(&w, &h);
+ printout->SetPageSizePixels((int)w, (int)h);
+
+ dc->GetSizeMM(&w, &h);
+ printout->SetPageSizeMM((int)w, (int)h);
+
+ // Create an abort window
+ wxBeginBusyCursor();
+
+ printout->OnPreparePrinting();
+
+ wxWindow *win = CreateAbortWindow(parent, printout);
+ wxYield();
+
+#if defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__)
+#ifdef STRICT
+ ::SetAbortProc((HDC) dc->GetHDC(), (ABORTPROC) m_lpAbortProc);
+#else
+ ::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) m_lpAbortProc);
+#endif
+#else
+ ::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *)
+ // cast it to right type only if required
+ // FIXME it's really cdecl and we're casting it to stdcall - either there is
+ // something I don't understand or it will crash at first usage
+#ifdef STRICT
+ (HDC, int)
+#else
+ ()
+#endif
+ )m_lpAbortProc);
+#endif
+
+ if (!win)