Killing the Parent of a Modal Dialog BoxLast reviewed: July 22, 1997Article ID: Q74474 |
3.00 3.10
WINDOWS
kbprg
The information in this article applies to:
SUMMARYAn application cannot destroy the parent of a modal dialog box. When the modal dialog box ends, control is returned to its parent. If the parent is destroyed, control is given to a nonexistent window and the application crashes. When a parent window receives the destroy message, it is too late to destroy a child modal dialog box. The destroyed dialog box does not return control until after all the existing messages are processed, including the final destruction of the parent window. Therefore, it is imperative that all generational parents of a modal dialog box be disabled and have no way of receiving a WM_DESTROY message while the modal dialog box is active.
MORE INFORMATIONThis situation does not affect modeless dialog boxes. Therefore, if the design of a system cannot rule out the above problem, use a modeless dialog box instead of a modal dialog box. Because the Task Manager can kill any program at any time, there is no absolute protection from the parent being closed. The optimal solution is to forgo modal dialog boxes in favor of modeless dialog boxes. When a modeless dialog box is created, it may disable its parental windows.
|
Additional reference words: 3.00 3.10 wm_close
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |