Link to home
Start Free TrialLog in
Avatar of Václav Jedlička
Václav Jedlička

asked on

How to preselect "pages" option in the print dialog (MFC)

I am trying to customize a print dialog in a MFC app.
I want the "pages" option to be preselected.

In CMyView::OnPreparePrinting(CPrintInfo* pInfo)
I added this at the end of the function:
      pInfo->SetMinPage(10);
      pInfo->SetMaxPage(20);
      pInfo->m_pPD->m_pd.nFromPage = 10;
      pInfo->m_pPD->m_pd.nToPage = 20;
      pInfo->m_pPD->m_nFlags |= PD_PAGENUMS;
      return DoPreparePrinting(pInfo);

When the print dialog comes up, the "all" option is preselected.
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Václav Jedlička
Václav Jedlička

ASKER

Thanks!
Vaclav
Unfortunately there is still a problem. If the range of pages is just one page, the "pages" option does not get preselected:

      pInfo->SetMinPage(10);
      pInfo->SetMaxPage(10);
      pInfo->m_pPD->m_pd.nFromPage = 10;
      pInfo->m_pPD->m_pd.nToPage = 10;
      pInfo->m_pPD->m_pd.Flags |= PD_PAGENUMS;
      return DoPreparePrinting(pInfo);

It prints correctly page 10, but the print dialog has option "all" selected
Hm - does this really matter a lot? I mean: why offer two options at all if there's only one page, regardless what options the user can select only that single page can be printed. IMO it would would make more sense to remove the page-selection completeley ...

Beside this: it might be complicated (and probably only possible with huge effort) to change this behavior, this dialog is a common dialog which is created and handled by Windows, to change behavior of this dialog with is not provided by its common implementation is quite hard.
There are many pages there. This code is for printing just the current page.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much!
Vaclav
You're welcome, I'm glad I could help ...

Have a nice weekend,

best regards,

ZOPPO