Re: Using custom dialog template for Pagesetup dialog
"domehead100" <[email protected]>
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <[email protected]> |
--- In [email protected], "arasakumaran" <arasakumaran@...> wrote: > > --- In [email protected], "domehead100" <domehead100@> wrote: > > > > --- In [email protected], "arasakumaran" <arasakumaran@> wrote: > > > > > > Hi. > > > > > > I need to customize the PageSetup dialog, extending the standard (Common) dialog with some additional control. I have a replacement dialog template that has the additonal controls and uses the standard control IDs for the ones that are part of the standard. > > > > > > Actually, I am converting an MFC class to WTL and am stuck a bit. In MFC, the new class is derived from CPageSetupDialog and uses the enum IDD= IDD_CUSTOM_TEMPLATE. In fact, it is just like a regular dialog class. Everything works as expected. > > > > > > However the WTL class for the Coomon Dialog PageSetup is not based on CDialogImpl, but CWindowImpl. Hence my difficulty - I don't know how to get the class to use my template, not the standard template. I also don't know how to set it up so that I use the HookProc. > > > > > > Is there an example that I can look at? Thanks. > > > > > > > I've never used CPageSetupDialog, but looking at the source in atldlgs.h shows: > > > > /////////////////////////////////////////////////////////////////////////////// > > // CPageSetupDialogImpl - Page Setup dialog > > > > #ifndef _WIN32_WCE > > > > template <class T> > > class ATL_NO_VTABLE CPageSetupDialogImpl : public CCommonDialogImplBase > > { > > public: > > PAGESETUPDLG m_psd; > > ATL::CWndProcThunk m_thunkPaint; > > ... > > > > Notice that the PAGESETUPDLG structure is a public member. So can't you just set the m_psd.lpSetupTemplateName or m_psd.hPageSetupTemplate member (depending on how you are doing it) to your custom template before calling DoModal()? > > > > ~Mike > > > > Thanks Mike. I had seen that about the same time. I now can get my dialog. But have not yet figured out how to use the HookProc, or even if I need to do it. May be I just place a message map and see if the messages get routed to my class. > Well, looking again at the source for CPageSetupDialogImpl, CPageSetupDialog, and CCommonDialogImplBase, it appears that the PageSetupHook and PagePaintHook are set up for you automatically. What I would look at is: 1) CPageSetupDialog. See how it is defined as : public CPageSetupDialogImpl<CPageSetupDialog>. If you want to use your own class instead of the generic CPageSetupDialog, declare it thusly. 2) CPageSetupDialogImpl::PaintHookProc. You will see that it will call your classes' functions for PreDrawPage, OnDrawPage, etc., if you implement them and don't have your own PaintHookProc which overrides the one in CPageSetupDialogImpl. Alternatively, look at CPageSetupDialog's PaintHookProc, to see how you can set it up so you can write your own complete paint hook proc (the one in CPageSetupDialog just returns 0). 3) CCommonDialogBase::HookProc. You will see that this really calls your classes' SubclassWindow and then hooks up your classes' message map. So it looks to me like you should be able to just add items to your message map for messages you are interested in, and the hook proc will make sure your message map is consulted when it receives callbacks from the dialog. Hope this helps. Like many things in WTL, it's sometimes an adventure, but usually it's worth it. ~Mike ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/wtl/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/wtl/join (Yahoo! ID required) <*> To change settings via email: mailto:[email protected] mailto:[email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/