Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 1.44 KB

destroying-the-dialog-box.md

File metadata and controls

16 lines (12 loc) · 1.44 KB
description title ms.date helpviewer_keywords ms.assetid
Learn more about: Destroying the Dialog Box
Destroying the Dialog Box
11/04/2016
dialog boxes [MFC], deleting
destruction, dialog box
dialog boxes [MFC], destroying
dialog boxes [MFC], removing
modeless dialog boxes [MFC], destroying
MFC dialog boxes [MFC], destroying
modal dialog boxes [MFC], destroying
dabceee7-3639-4d85-bf34-73515441b3d0

Destroying the Dialog Box

Modal dialog boxes are normally created on the stack frame and destroyed when the function that created them ends. The dialog object's destructor is called when the object goes out of scope.

Modeless dialog boxes are normally created and owned by a parent view or frame window — the application's main frame window or a document frame window. The default OnClose handler calls DestroyWindow, which destroys the dialog-box window. If the dialog box stands alone, with no pointers to it or other special ownership semantics, you should override PostNcDestroy to destroy the C++ dialog object. You should also override OnCancel and call DestroyWindow from within it. If not, the owner of the dialog box should destroy the C++ object when it is no longer necessary.

See also

Working with Dialog Boxes in MFC