Ok, then if the property sheet is allocating memory for the pages, it should also free up that memory. Something like:
class MySheet : public CPropertySheet
{
MyPage *page1;
MyPage *page2;
MyPage *page3;
};
MySheet::MySheet()
{
page1 = new MyPage;
AddPage(page1);
page2 = new MyPage;
AddPage(page2);
page3 = new MyPage;
AddPage(page3);
}
MySheet::~MySheet()
{
delete page1;
delete page2;
delete page3;
}
BOOL MySheet::OnCommand( WPARAM wParam, LPARAM lParam )
{
WORD wNotifyCode,
wId;
wId = LOWORD(wParam);
wNotifyCode = HIWORD(wParam);
if (BN\_CLICKED == wNotifyCode)
{
if (IDOK == wId)
{
if (! ProcOk())
return TRUE;
}
}
return CPropertySheet::OnCommand(wParam, lParam);
}
// the OK button was clicked
BOOL MySheet::ProcOk( void )
{
if (::IsWindow(page1->m_hWnd))
{
if (! page1->OnKillActive())
return FALSE;
}
if (::IsWindow(page1->m\_hWnd))
page1->OnOK();
return TRUE;
}
void MyPage::OnOK()
{
// the sheet is about to go away.
// do any page-specific cleanup here
CPropertyPage::OnOK();
}
BOOL MyPage::OnKillActive()
{
// the page is being changed.
// do any page-specific validation here.
// return 0 if the page should not change
return CPropertyPage::OnKillActive();
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb