-
October 3rd, 2000, 08:27 PM
#1
Invalid parent
From a Dynyamicaly created Dlg trying to post a message to the parent to delete the ptr allocated for this Dlg.
However Can not find the valid Ptr to the parent ..
***Parent is Invalid****
Does anyone know why ?
Ta
LONG CCallTypeDialog::OnClickedDlg(UINT ,LONG )
{
this->DestroyWindow();
CDialog::OnDestroy();
CWnd* pParent = GetParent();
if(pParent)
{
log("Parent is Valid");
pParent->PostMessage(m_WM_KILL_ME_DAD,0,(long)this);
}
else
{
log("Parent is ***INVALID****");
}
log("OnClickedDlg -Done");
return 0L;
}
Code in the parent:
LONG CWndTca::OnKillMeDad(UINT , LONG addr)
{
log("****OnKillMeDad****");
char s[20];
sprintf(s,"address is %ld",addr);
log(s);
if((CCallTypeDialog *)addr)
delete (CCallTypeDialog *)addr ;
return 0L;
}
Using Java version on windows 1.8_51
-
October 3rd, 2000, 08:45 PM
#2
Re: Invalid parent
try this order :
LONG CCallTypeDialog::OnClickedDlg(UINT ,LONG )
{
CWnd* pParent = GetParent();
if(pParent)
{
log("Parent is Valid");
pParent->PostMessage(m_WM_KILL_ME_DAD,0,(long)this);
}
else
{
log("Parent is ***INVALID****");
}
log("OnClickedDlg -Done");
CDialog::OnDestroy();
return 0L;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|