Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

About CPropertySheet::OnInitDialog

212 views
Skip to first unread message

Hu Dong

unread,
Jul 16, 2004, 1:40:43 PM7/16/04
to
I created a class derived from CPropertySheet. In the override method
OnInitDialog(), I want to call the base method
CPropertySheet::OnInitDialog() first. However, the compiler complaint that
OnInitDialog() is not a method in the CPropertySheet class. I did not find
this method record from the intellisense window followed by
CPropertySheet::. I really got confused because the MSDN library says very
clearly that this method shall exist!

Anybody has any ideas? Please write down something if you have any
suggestions!

Thanks!!!

Hu


Scott McPhillips [MVP]

unread,
Jul 16, 2004, 6:41:49 PM7/16/04
to

CPropertySheet is not derived from CDialog and does not have an
OnInitDialog method. Your code to initialize the property sheet should
be put in the constructor of your CPropertySheet-derived class.

--
Scott McPhillips [VC++ MVP]

Pierre Couderc

unread,
Jul 17, 2004, 10:11:33 AM7/17/04
to
CPropertySheet is derived from Cwnd but has a OnInitDialog() method in
VC6. Anyway, it is not in the documentation!

Pierre Couderc

Jeff Partch [MVP]

unread,
Jul 17, 2004, 10:44:38 AM7/17/04
to
"Hu Dong" <hd...@ucdavis.edu.INVALID> wrote in message
news:uDVbGw1...@tk2msftngp13.phx.gbl...

> I created a class derived from CPropertySheet. In the override method
> OnInitDialog(), I want to call the base method
> CPropertySheet::OnInitDialog() first. However, the compiler complaint that
> OnInitDialog() is not a method in the CPropertySheet class.

I can't figure why the compiler is complaining -- CPropertySheet does indeed
have a public: virtual BOOL OnInitDialog() member function (in both MFC42
and MFC71). In a quick test, I get no error(s) at all deriving, overriding
and calling the base implementation using either MFC version.
--
Jeff Partch [VC++ MVP]


Christopher J. Holland

unread,
Jul 17, 2004, 11:05:32 AM7/17/04
to
"Even though CPropertySheet is not derived from CDialog,
managing a CPropertySheet object is similar to managing a CDialog object."
Since it is similar to a Dialog, they just reuse the same functions.
So, yes, CPropertySheet does have a OnInitDialog() Member function.
Even though it does not inherit from CDialog.
Who knows why they didn't bother to rename the function.
Either they were to lazy to change it, or maybe
they might want to add functionality later on.

>>In the override method
>>OnInitDialog(), I want to call the base method
>>CPropertySheet::OnInitDialog() first.

When you over-ride OnInitDialog(), in either
the CPropertyPage or the CPropertySheet,
The Base class OnInitDialog will be automatically inserted.

BOOL CPageWav::OnInitDialog()
{
CPageX::OnInitDialog(); //My Base class. Yours would be
CPropertyPage::OnInitDialog().
...
}

BOOL CPropertySheetX::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
return bResult;
}

I think you have a problem, such as not inheriting from CPropertySheet,
or some other problem.

Check the following functions to make sure you are inheriting from
CPropertySheet.
class CPropertySheetX : public CPropertySheet
BEGIN_MESSAGE_MAP(CPropertySheetX, CPropertySheet)
IMPLEMENT_DYNAMIC(CPropertySheetX, CPropertySheet)
CPropertySheetX::CPropertySheetX(CWnd* pParentWnd, CDocXX *pDoc)
:CPropertySheet(AFX_IDS_APP_TITLE, pParentWnd)
Those will screw you up, if they are not correct.

Regards,
--
Christopher J. Holland [!MVP]
http://www.mvps.org/vcfaq/
http://www.codeguru.com
http://www.codeproject.com
http://www.naughter.com/
http://support.microsoft.com/default.aspx
http://msdn.microsoft.com/howto/
http://msdn.microsoft.com/library/
http://www3.pgh.net/~newcomer

"Pierre Couderc" <pie...@couderc.ccNOSPAM> wrote in message
news:cdbc2s$19q0$1...@biggoron.nerim.net...

0 new messages