MFC Question

Started by
5 comments, last by B.o.t.G. 24 years, 6 months ago
I have a little problem. I want to create an application with a wizard-dialog based on CPropertySheet. I have created several pages (based on CPropertyPage). Now I want to change the buttons displayed on bottom of the wizard. I think I have to use CPropertySheet::SetWizardButtons. But how to access this function from within a property page? The help tells me to use this function within the OnSetActive memberfunction of the property page. Please help! B.o.t.G. -------- Writer of the VQAtoAVI conversation utility for CC
B.o.t.G.--------Writer of- VQAtoAVI, the conversation utility for C&C- Golden Cow, the BO2K attacher
Advertisement
Like many situations in MFC, the property page is considered a child of the property sheet. So, what you need to do, is use GetParent, within your property page, like so:

CPropertySheet* pSheet = (CPropertySheet*)GetParent();

Then you can call any of the sheet functions at your discretion.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Thanks for your reply, but I have found another way. I created the member-variable CPropertySheet *m_pOwner
and assign it the address of my CPropertySheet class during startup of the dialog

B.o.t.G.
--------

Writer of the VQAtoAVI conversation utility for CC
B.o.t.G.--------Writer of- VQAtoAVI, the conversation utility for C&C- Golden Cow, the BO2K attacher
Actually that's another excellent way of getting a route to your parent classes in MFC, especially if you want to be absolutely sure of where you are getting the information from... some people don't totally trust MFC to get the parent correctly for them (imagine that... *grin*)

-fel


Edited by - felisandria on 2/17/00 4:46:59 PM
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
GetParent only returns the most immediate parent.
It most definitely does not recursively search up
the window hierarchy searching for the type you
specify. What gets returned to you looks like a
CPropertySheet in this case because you cast it to
a CPropertySheet.

From the MFC source with MSVC 6.0:

_AFXWIN_INLINE CWnd* CWnd::GetParent() const
{ ASSERT(::IsWindow(m_hWnd)); return CWnd::FromHandle(::GetParent(m_hWnd)); }

There''s nothing tricky going on there.

GetParentOwner might be more appropriate call in
this situation - it turns the most immediate parent
window that is not a child of another window.


All these different methods with all these problems. I prefer the direct method: passing the parent-window as parameter

B.o.t.G.
--------

Writer of the VQAtoAVI conversation utility for CC
B.o.t.G.--------Writer of- VQAtoAVI, the conversation utility for C&C- Golden Cow, the BO2K attacher
Oops, sorry, I just realized that the GetParent recursive stuff isn''t native to MFC, it''s an override we throw in here because we do it so much. LordFoul is right, hope I didn''t confuse anyone too much.
It is a nifty thing to have tho.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~

This topic is closed to new replies.

Advertisement