我通过m_dlgInfo.Create(CDlgInfo::IDD, this)创建了一个现实信息的dialog,create最后返回了true,但是查看对象发现其m_pParentWnd=0x00000000,这是怎么回事?this肯定不为空啊

解决方案 »

  1.   

    创建对话框第二个可以不传数据的,this肯定是空,因为你还没Create成功
      

  2.   


    this不为空,this是父窗口指针,父窗口早就创建完毕了,不是在父窗口创建的时候调用上面的create
      

  3.   

    virtual BOOL Create(
       LPCTSTR lpszTemplateName,
       CWnd* pParentWnd = NULL 
    );
    virtual BOOL Create(
       UINT nIDTemplate,
       CWnd* pParentWnd = NULL 
    );
     
    Parameters
    lpszTemplateName
    Contains a null-terminated string that is the name of a dialog-box template resource. pParentWnd
    Points to the parent window object (of type CWnd) to which the dialog object belongs. If it is NULL, the dialog object's parent window is set to the main application window. 
      

  4.   

    在Create里面不会设置m_pParentWnd,只有在构造函数还有InitModalIndirect类似的函数里面才会设置m_pParentWnd,你可以尝试先new mydlginfo(this),再Create,