请问pchildfrm->DestroyWindow()的作用是删除了pchildfrm所连的窗口还是删除了pchildfrm整个对象

解决方案 »

  1.   

    CWnd::DestroyWindow  
    virtual BOOL DestroyWindow( );Return ValueNonzero if the window is destroyed; otherwise 0.如果销毁了窗口,则返回非零值;否则返回0。 ResDestroys the Windows window attached to the CWnd object. The DestroyWindow member function sends appropriate messages to the window to deactivate it and remove the input focus. It also destroys the window’s menu, flushes the application queue, destroys outstanding timers, removes Clipboard ownership, and breaks the Clipboard-viewer chain if CWnd is at the top of the viewer chain. It sends WM_DESTROY and WM_NCDESTROY messages to the window. It does not destroy the CWnd object.这个函数销毁一个与CWnd对象相连接的Windows窗口。DestroyWindow成员函数向窗口发送一个适当的消息,以使该窗口变为非激活的并移去输入焦点。它还销毁窗口的菜单,清除应用程序的队列,销毁定时器,清除剪贴板拥有权,并且如果CWnd对象位于剪贴板观察器链的顶部,还打断剪贴板观察器链。它向窗口发送WM_DESTROY消息和WM_NCDESTROY消息。它不销毁CWnd对象 
      

  2.   

    DestroyWindow是一个用于执行清除工作的占位符。因为DestroyWindow是一个虚拟函数,在ClassWizard中,它显示在任何CWnd的派生类中。但是即使你在自己的CWnd派生类中重载了这个函数,也不必调用DestroyWindow。如果在MFC代码中没有调用DestroyWindow,并且你希望调用它的话,必须在自己的代码中调用它。 
    例如,假定你在CView的派生类中重载了DestroyWindow。由于MFC的源代码在任何CFrameWnd的派生类中都没有调用DestroyWindow,因此除非你调用了它,否则你重载的DestroyWindow不会被调用。 如果该窗口是其它窗口的父窗口,当父窗口被销毁时,这些子窗口将被自动销毁。DestroyWindow成员函数首先销毁子窗口,然后销毁本窗口。 DestroyWindow成员函数也销毁CDialog::Create创建的无模式对话框。 如果要被销毁的CWnd是一个子窗口并且没有设置WS_EX_NOPARENTNOTIFY风格,则WM_PARENTNOTIFY消息将被发送到父窗口。
      

  3.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cwnd.3a3a.destroywindow.asp
      

  4.   

    THANK YOU  不过我做了实验确实是删除了对象,不过pchildfrm是CMDIChildWnd对象 可能CMDIChildWnd继承了CWND后行为有变? 我没做过实验不知道。总之谢谢!