same propertypage in 2 dialogs? (one calling the other)
- From: ".rhavin grobert" <clqrq@xxxxxxxx>
- Date: 8 Oct 2006 09:20:16 -0700
i have a property*** with 3 pages:
______________________________________________________________
// in header Main***.h
CStandard m_standard;
CErweitert m_erweitert;
CListe m_liste;
______________________________________________________________
// in implementation Main***.cpp
CMain***::CMain***()
: CProperty*** (IDS_TITLE)
{
AddPage (&m_standard);
AddPage (&m_erweitert);
AddPage (&m_liste);
}
i have another dialog (CRecall) were i want to have the 2nd page
(m_erweitert) [btw: german for 'extended'] as a child inside a static
(m_REParent). this should work like this: the user pushes a button
inside page#1 'm_standard' (or page#0 if you prefer ;-)) and my 2nd
dialog pops up modaly, consisting of some controls and the whole page
#2 (or page#1 if you start at the zeroth) that works like this:
______________________________________________________________
// in header Recall.h
CErweitert * DlgErweitert;
bool fErweitertCreated;
______________________________________________________________
// in implementation Recall.cpp
CRecall::CRecall(CWnd* pParent /*=NULL*/)
: CDialog(CRecall::IDD, pParent)
{fErweitertCreated = false;}
BOOL CRecall::OnInitDialog() {
CDialog::OnInitDialog();
RECT rc;
m_REParent.GetWindowRect(&rc);
ScreenToClient(&rc);
if (! DlgErweitert->GetSafeHwnd()) {
//if user clicked on "recall" before
//he clicked on Property***.erweitert..
// if we dont check it, we get assertion-error
DlgErweitert->Create(IDD_ERWEITERT,this);
fErweitertCreated = true;
}
DlgErweitert->SetParent(this);
rc.left -= GetSystemMetrics(SM_CXBORDER);
DlgErweitert->ModifyStyle(WS_CAPTION|WS_DISABLED,WS_VISIBLE|WS_CLIPCHILDREN,1);
DlgErweitert->EnableWindow(true);
DlgErweitert->MoveWindow(&rc,true);
return false;
}
int CRecall::DoModal() {
int ret = CDialog::DoModal();
if (fErweitertCreated) DlgErweitert->DestroyWindow();
return ret;
}
however, when user clickes on the button that should bring up my 2nd
dialog (yes, we could call it my 1st if we call the other 0th ;-))
*before* m_erweitert was visible, i got faults until i added...
if (! DlgErweitert->GetSafeHwnd()) {
DlgErweitert->Create(IDD_ERWEITERT,this);
}
....to my dialog. so by now, the m_erweitert is shown independent of its
former creation. but then i had the problem that my dialog crashes
*after* i close it and click on the m_erweitert's tab or if i call my
2nd dialog a 2nd time.
i thought i should destroy (should i?) DlgErweitert in my CRecall *if*
i created it there (i store this in a bool) but now my m_erweitert is
gone after i call my CRecall.
so what should i do?
.
- Prev by Date: Re: IWebBrowser2 use too much memory
- Next by Date: Re: Creating a CListCtrl
- Previous by thread: what files to include when distributing an activex
- Next by thread: Re: winlogon notify
- Index(es):