+ HDC hdc = ::GetDC(NULL);
+ int logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
+ int logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
+ ::ReleaseDC(NULL, hdc);
+
+ int logPPIPrinterX = ::GetDeviceCaps((HDC) impl->GetHDC(), LOGPIXELSX);
+ int logPPIPrinterY = ::GetDeviceCaps((HDC) impl->GetHDC(), LOGPIXELSY);
+ if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
+ {
+ delete dc;
+ sm_lastError = wxPRINTER_ERROR;
+ 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);
+ printout->SetPaperRectPixels(dc->GetPaperRect());
+
+ dc->GetSizeMM(&w, &h);
+ printout->SetPageSizeMM((int)w, (int)h);
+
+ // Create an abort window
+ wxBusyCursor busyCursor;
+
+ printout->OnPreparePrinting();
+
+ // Get some parameters from the printout, if defined
+ int fromPage, toPage;
+ int minPage, maxPage;
+ printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
+
+ if (maxPage == 0)
+ {
+ sm_lastError = wxPRINTER_ERROR;
+ return false;
+ }
+
+ // Only set min and max, because from and to have been
+ // set by the user
+ m_printDialogData.SetMinPage(minPage);
+ m_printDialogData.SetMaxPage(maxPage);
+
+ wxWindow *win = CreateAbortWindow(parent, printout);
+ wxYield();
+
+#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__GNUWIN32__) || !defined(__WIN32__)
+#ifdef STRICT
+ ::SetAbortProc((HDC) impl->GetHDC(), (ABORTPROC) m_lpAbortProc);
+#else
+ ::SetAbortProc((HDC) impl->GetHDC(), (FARPROC) m_lpAbortProc);
+#endif
+#else
+ ::SetAbortProc((HDC) impl->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)
+ {
+ wxLogDebug(wxT("Could not create an abort dialog."));
+ sm_lastError = wxPRINTER_ERROR;
+
+ delete dc;
+ return false;
+ }
+ sm_abortWindow = win;
+ sm_abortWindow->Show();
+ wxSafeYield();
+
+ printout->OnBeginPrinting();
+
+ sm_lastError = wxPRINTER_NO_ERROR;
+
+ int minPageNum = minPage, maxPageNum = maxPage;
+
+ if ( !m_printDialogData.GetAllPages() )