Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Print unwanted copy
Re: Print unwanted copy [message #44117 is a reply to message #44116] |
Thu, 25 December 2014 20:56 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Well, it looks like this really is Microsoft bug, see "known issue" for PD_USEDEVMODECOPIESANDCOLLATE
http://msdn.microsoft.com/en-us/library/windows/desktop/ms64 6843%28v=vs.85%29.aspx
In any case, I have now tried the workaround proposed by KB, which basically says "always depend to OS/Driver to do copies".
Please try this:
bool PrinterJob::Execute0(bool dodlg)
{
pdlg = new Win32PrintDlg_;
PRINTDLG& dlg = *pdlg;
dlg.Flags = PD_DISABLEPRINTTOFILE|PD_NOSELECTION|PD_HIDEPRINTTOFILE|PD_RETURNDEFAULT;
dlg.nFromPage = current;
dlg.nToPage = current;
dlg.nMinPage = from;
dlg.nMaxPage = to;
if(from != to)
dlg.Flags |= PD_ALLPAGES;
dlg.hwndOwner = 0;
dlg.Flags |= PD_RETURNDEFAULT;
dlg.nCopies = 1;
if(!PrintDlg(&dlg)) return false;
if(dlg.hDevMode) {
DEVMODE *pDevMode = (DEVMODE*)::GlobalLock(dlg.hDevMode);
pDevMode->dmOrientation = landscape ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT;
::GlobalUnlock(dlg.hDevMode);
}
HDC hdc;
if(dodlg) {
dlg.Flags = PD_DISABLEPRINTTOFILE|PD_NOSELECTION|PD_HIDEPRINTTOFILE|PD_RETURNDC|PD_USEDEVMODECOPIESANDCOLLATE;
Vector< Ptr<Ctrl> > disabled = DisableCtrls(Ctrl::GetTopCtrls());
bool b = PrintDlg(&dlg);
EnableCtrls(disabled);
if(!b) return false;
hdc = dlg.hDC;
}
else {
DEVNAMES *p = (DEVNAMES *)::GlobalLock(dlg.hDevNames);
const char *driver = (const char *)p + p->wDriverOffset;
const char *device = (const char *)p + p->wDeviceOffset;
if(dlg.hDevMode) {
DEVMODE *pDevMode = (DEVMODE*)::GlobalLock(dlg.hDevMode);
hdc = CreateDC(driver, device, NULL, pDevMode);
::GlobalUnlock(dlg.hDevMode);
}
else
hdc = CreateDC(driver, device, NULL, NULL);
}
if(dlg.hDevMode)
::GlobalFree(dlg.hDevMode);
if(dlg.hDevNames)
::GlobalFree(dlg.hDevNames);
if(hdc) {
draw = new PrintDraw(hdc, Nvl(name, Ctrl::GetAppName()));
page.Clear();
if(!(dlg.Flags & PD_PAGENUMS)) {
dlg.nFromPage = dlg.nMinPage;
dlg.nToPage = dlg.nMaxPage;
}
// for(int c = 0; c < ((dlg.Flags & PD_COLLATE) ? dlg.nCopies : 1); c++)
for(int i = dlg.nFromPage - 1; i <= dlg.nToPage - 1; i++)
// for(int c = 0; c < ((dlg.Flags & PD_COLLATE) ? 1 : dlg.nCopies); c++)
page.Add(i);
return true;
}
return false;
}
(also in trunk, for now).
Mirek
|
|
|
|
|
Print unwanted copy
By: forlano on Sun, 21 December 2014 14:15
|
|
|
Re: Print unwanted copy
By: Klugier on Sun, 21 December 2014 22:54
|
|
|
Re: Print unwanted copy
By: forlano on Mon, 22 December 2014 08:46
|
|
|
Re: Print unwanted copy
By: Klugier on Mon, 22 December 2014 16:29
|
|
|
Re: Print unwanted copy
By: forlano on Mon, 22 December 2014 18:30
|
|
|
Re: Print unwanted copy
By: mirek on Thu, 25 December 2014 11:09
|
|
|
Re: Print unwanted copy
By: forlano on Thu, 25 December 2014 14:06
|
|
|
Re: Print unwanted copy
By: mirek on Thu, 25 December 2014 20:44
|
|
|
Re: Print unwanted copy
By: mirek on Thu, 25 December 2014 20:56
|
|
|
Re: Print unwanted copy
By: forlano on Thu, 25 December 2014 22:01
|
Goto Forum:
Current Time: Thu Apr 25 07:21:19 CEST 2024
Total time taken to generate the page: 0.03631 seconds
|