정리

[MFC] DestroyWindow

저장소/VC++

DestroyWindow에 대한 MSDN 발췌 내용은 다음과 같다.

The DestroyWindow function destroys the specified window. The function sends WM_DESTROY and WM_NCDESTROY messages to the window to deactivate it and remove the keyboard focus from it. The function also destroys the window's menu, flushes the thread message queue, destroys timers, removes clipboard ownership, and breaks the clipboard viewer chain (if the window is at the top of the viewer chain).

If the specified window is a parent or owner window, DestroyWindow automatically destroys the associated child or owned windows when it destroys the parent or owner window. The function first destroys child or owned windows, and then it destroys the parent or owner window.

다음은 CWnd의 DestroyWindow에 대한 내용이다.

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.

DestroyWindow is a place holder for performing cleanup. Because DestroyWindow is a virtual function, it is shown in any CWnd-derived class in Class View. But even if you override this function in your CWnd-derived class, DestroyWindow is not necessarily called. If DestroyWindow is not called in the MFC code, then you have to explicitly call it in your own code if you want it to be called.

Assume, for example, you have overridden DestroyWindow in a CView-derived class. Since MFC source code does not call DestroyWindow in any of its CFrameWnd-derived classes, your overridden DestroyWindow will not be called unless you call it explicitly.

If the window is the parent of any windows, these child windows are automatically destroyed when the parent window is destroyed. The DestroyWindow member function destroys child windows first and then the window itself.

이러저러한 얘기는 많지만 내가 알고싶었던 것은 Child Window를 Destroy 하느냐 마느냐였는데 잘 나와있다.

알고 쓰고 정리하자. ㅠㅠ

'저장소 > VC++' 카테고리의 다른 글

[Debugging] First-chance Exception과 Second-chance Exception  (0) 2012.01.12
[Win32 API] GetAsyncKeyState  (0) 2011.11.25
[MFC] MainFrame 크기 고정  (0) 2011.10.21
[Win32 API] Window Styles  (0) 2011.10.10
[MFC] CFileDialog 사용 주의점  (0) 2011.09.23