mercredi 9 juin 2021

Error using GetPrinterDeviceDefaults with MFC

I'm working with CPrintDialog with a very straightforward scenario where I have this:

std::unique_ptr<CPrintInfo> print_info_ptr(new CPrintInfo); 
PRINTDLG& print_dlg = print_info_ptr->m_pPD->m_pd;
AfxGetApp()->GetPrinterDeviceDefaults(&print_dlg)

Now, imagine you have a button that runs this code every time it's clicked. Well, the first time I click the button and the CPrintDialog is shown, if I change the current printer in the CPrintDialog and I click OK, I cannot open the CPrintDialog again cause PRINTDLG& print_dlg = print_info_ptr->m_pPD->m_pd; fails saying "Encountered an improper argument"

Do you have any idea to help here?

Thank you very much

Aucun commentaire:

Enregistrer un commentaire