Article ID: 201553
Article Last Modified on 11/21/2006
CMenu *pSysMenu = GetSystemMenu(FALSE); ASSERT(pSysMenu != NULL); VERIFY(pSysMenu->RemoveMenu(SC_CLOSE, MF_BYCOMMAND));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:
// CChildFrame is a CMDIChildWnd-derived class.
void CChildFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_CLOSE)
return;
CMDIChildWnd::OnSysCommand(nID, lParam);
}
(c) Microsoft Corporation 1999, All Rights Reserved. Contributions
by Isaac L. Varon, Microsoft Corporation.Additional query words: ChildFrame MainFrame
Keywords: kbhowto kbmdi kbmenu kbuidesign KB201553