CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Invalid parent

  1. #1
    Join Date
    May 1999
    Location
    G day Mayt Land
    Posts
    971

    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

  2. #2
    Join Date
    May 1999
    Location
    Romania
    Posts
    70

    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
  •  





Click Here to Expand Forum to Full Width

Featured