From: Vadim Zeitlin Date: Sun, 26 May 2013 13:14:38 +0000 (+0000) Subject: Fix printing multiple copies in wxMSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a7587bc4a2585974638c86f22e7ce682688ca983?ds=sidebyside Fix printing multiple copies in wxMSW. If wxPrinterDC was created by the native "Print" dialog for a printer that supports printing multiple copies, we must not manually print multiple copies ourselves as this results in too many copies being printed. However we still need to loop explicitly for wxPrinterDC objects created manually or for the printers without support for multiple copies (supposing they still exist). Closes #10323. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74055 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index 03eeb53fd3..f64bc4e691 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -697,6 +697,7 @@ wxMSW: - Return more native shell icons from wxArtProvider (Markus Juergens). - Fix filter checks in wxDir::FindFirst/Next() (Catalin Raceanu). - Add support for wxICON_AUTH_NEEDED to wxMessageDialog (Chris Spencer). +- Fix printing too many copies of the document in some cases (John Roberts). wxOSX/Cocoa: diff --git a/src/msw/printwin.cpp b/src/msw/printwin.cpp index 0c8a2ed652..62abb589f6 100644 --- a/src/msw/printwin.cpp +++ b/src/msw/printwin.cpp @@ -196,7 +196,14 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt maxPageNum = m_printDialogData.GetToPage(); } - const int maxCopyCount = m_printDialogData.GetNoCopies(); + // The dc we get from the PrintDialog will do multiple copies without help + // if the device supports it. Loop only if we have created a dc from our + // own m_printDialogData or the device does not support multiple copies. + // m_printDialogData.GetPrintData().GetNoCopies() is set from device + // devMode in printdlg.cpp/wxWindowsPrintDialog::ConvertFromNative() + const int maxCopyCount = !prompt || + !m_printDialogData.GetPrintData().GetNoCopies() + ? m_printDialogData.GetNoCopies() : 1; for ( int copyCount = 1; copyCount <= maxCopyCount; copyCount++ ) { if ( !printout->OnBeginDocument(minPageNum, maxPageNum) )