Hi Hari,
I have inspected my code of an analog task
and found some diferences (compared to my words "in the past")... :-O :)
Neither the parent context nor the child call
DestroyWindow()
...
Instead the function
EndDialog(IDCANCEL)
will be used for each child there...
Please observe my fragments below:
CProfileEngine::CProfileEngine(CProjektRT* pcProjekt)
{
SetProjekt(pcProjekt);
m_cszLastUserRef = USER_TITEL_SYS;
m_pcDialog = NULL;
ResetReception();
}
Since my parent is not a window, I have the the clearance at its destructor,
your correct place would be probably
CParentDlg::OnDestroy()
:
CProfileEngine::~CProfileEngine()
{
if (m_pcDialog) {
if (m_pcDialog->GetSafeHwnd()) {
m_pcDialog->EndDialog(IDCANCEL); }
delete m_pcDialog;
}
}
Here is the activation stage:
void CProfileEngine::Administrate()
{
if (!m_pcDialog) {
m_pcDialog = new CProfileDlg(this, ::AfxGetMainWnd()); }
if (m_pcDialog && !m_pcDialog->m_hWnd) {
if (m_pcDialog->Create(CProfileDlg::IDD, ::AfxGetMainWnd())) { }
}
if (m_pcDialog && m_pcDialog->m_hWnd) {
m_pcDialog->ShowWindow(SW_SHOW); m_pcDialog->SetFocus();
}
}
And the closing reaction of the child (maybe you do not need it generally):
void CProfileDlg::OnCloseBox()
{
CD_CTranslateDlg::OnCancel(); }
Please try to replace all children's
DestroyWindow()
by
EndDialog(IDCANCEL)
.
Sorry - for my complicated prelude :)