Im trying to add printing fucntionality to my app. I display the CPrintDialog to get the printer options. How do I get the printing range option enabled ? Currently this option is disabled when i doModal() the dialog.
A:
What arguments are you passing to the CPrintDialog constructor? The constructor is declared as
CPrintDialog(BOOL bPrintSetupOnly,
DWORD dwFlags = PD_ALLPAGES|PD_USEDEVMODECOPIES|PD_NOPAGENUMS|
PD_HIDEPRINTTOFILE|PD_NOSELECTION,
CWnd* pParentWnd = NULL);
so if you don't supply a value for the "dwFlags" argument, you'll get those default flags. The default flags includes PD_NOPAGENUMS, so the page selection controls will be disabled. You've also got to set the maximum page number, too, for the page selection controls to work. Try changing your code to something like
CPrintDialog dlg(FALSE,
PD_ALLPAGES|PD_USEDEVMODECOPIES|PD_HIDEPRINTTOFILE|PD_NOSELECTION);
dlg.m_pd.nMaxPage = 100;
dlg.DoModal();
DavidK
2009-07-02 12:13:28
No luck. Did you try this on a test project. Doesn't seem to work even on a Release build. Let me know if it works for you. I guess there's a special way to handle range selection, I remember reading somewhere (cant recollect). Btw, my project is NOT based on doc/view and is only a dialog based application. Could this be the reason ? appreciate your help much.
2009-07-03 10:02:40
I didn't actually test it, sorry about that. Now I have, I can see that you also need to set the maximum page number for those controls to be enabled: I've edited my answer above to reflect this, and it at least works for me.The problem isn't related to you not using DocView - the CPrintDialog itself is just a thin wrapper around Windows' native print dialog. Actually doing some printing without DocView may be hearder, but that's a different problem...
DavidK
2009-07-07 09:03:22
A:
Does your printing code set the amount of pages that are going to be printed? I don't have any code at hand but I think it's in OnPreparePrintDC() or something like that, where you set m_MaxPage or so member of the object you get as an argument.
Roel
2009-07-06 10:31:22