子窗口和父窗口的关系是一种依附关系,父窗口好像是一个容器,窗口在windows中 是一种资源,他们都有句柄标示,但小弟还是不太懂windows中的父窗口关系。例如在下面的例子中:
void CMyDlg::OnCreateStatic() 
{
   CWnd* pWnd = new CWnd;
   pWnd->Create(_T("STATIC"), "Hi", WS_CHILD | WS_VISIBLE,
       CRect(0, 0, 20, 20), this, 1234);
}
在这个virtual BOOL Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);函数中CWnd* pParentWnd指的是父窗口的指针,但在msdn中它的解释是The parent window。这是怎么回事??糊涂了。The parent window指的应该是一个窗口句柄吧!

解决方案 »

  1.   

    这是原型:
    Call to create and initialize the Windows frame window associated with the CFrameWnd object. 
    virtual BOOL Create(
       LPCTSTR lpszClassName,
       LPCTSTR lpszWindowName,
       DWORD dwStyle = WS_OVERLAPPEDWINDOW,
       const RECT& rect = rectDefault,
       CWnd* pParentWnd = NULL,
       LPCTSTR lpszMenuName = NULL,
       DWORD dwExStyle = 0,
       CCreateContext* pContext = NULL 
    );
     
      

  2.   

    void CMyDlg::OnCreateStatic() 
    {
       CWnd* pWnd = new CWnd;
       pWnd->Create(_T("STATIC"), "Hi", WS_CHILD | WS_VISIBLE,
           CRect(0, 0, 20, 20), this, 1234);
    }
    那在此中这个this指的是??pWnd???
      

  3.   

    那在此中这个this指的是??pWnd???
    //////////////////////////////////
    这里的this不正是CWnd*指针吗?
      

  4.   

    不是pWnd,
    this是当前类对象的指针。是CMyDlg的对象。
    CWnd ,pWnd ,HWND,看名字前缀可以知道什么类型。第一个是MFC里的类,第2是指向该类的指针,第3个是句柄(h-   handle)