The information in this article applies to:
SUMMARYThis article describes how to disable the close button in the title bar of the main frame and child frame windows of an MFC Multiple Document Interface (MDI) application. MORE INFORMATION
In some circumstances you may want to prevent the user from clicking the close button in the window's title bar to close a frame window in an MFC application. The close button can be removed by removing the WS_SYSMENU style from the frame window. However, the minimize, maximize, and restore buttons are also removed and cannot be added. This is in accordance to the design of Windows.
When the child frame window is not maximized, the above code prevents the user from closing the child frame window by clicking the close button. When the child frame window is maximized, the above code makes the close button appear disabled. However, a user can still close the child frame window by clicking this window's close button. You can prevent this by trapping the SC_CLOSE command when it is sent to the child frame window and preventing further processing of this command. To do so, use the WM_SYSCOMMAND message handler for the child frame's class, as in the following example:
(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Isaac L. Varon, Microsoft Corporation. Additional query words: ChildFrame MainFrame
Keywords : kbMDI kbMFC KbUIDesign kbVC600 |
Last Reviewed: January 21, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |