How to detect (or better prevent) print drivers making multiple copies in MS MFC (C++)
Posted on 2015-01-25
My MS C++ 2010 MFC application has the ability to print multiple copies. I tried to tell the MFC that I'll take care of multiple copies, but the print driver prints them anyway. So, when the user asks for 3, he gets 3 from me times 3 from the print driver, or 9.
In OnPreparePrinting, I put in before the call to DoPreparePrinting, the following:
pInfo->m_pPD->m_pd.Flags &= ~PD_USEDEVMODECOPIESANDCOLLATE; // clear flag in order to show I'll handle
pInfo->m_pPD->m_pd.Flags |= PD_COLLATE; // collate defaults on
pInfo->m_pPD->m_pd.Flags |= PD_RETURNDC; // need DC
In OnBeginPrinting, nCopies shows 3, and dmCopies shows 1. So I think I'm supposed to print 3, but the print driver is also handling, so I'm getting the 9 as described above.
1. Is there a way to prevent the driver from printing multiple copies in addition to mine?
2. Is there a way to figure out that the driver is doing the 3 copies, so that I stop my software only makes multiple copies when I find out that print driver can't handle multiple copies?