Click to See Complete Forum and Search --> : Disabling 'CLOSE' button


April 9th, 1999, 07:11 AM
I've a SDI application which I wonder how can I disable the 'CLOSE' button located at the top right hand corner of the application during run-time.
Thanks for any suggestion.

MikeL
April 9th, 1999, 07:28 AM
Add a return statement to OnClose() function of CMainFrame (or whatever) so that the default CMainFrame::OnClose() does not get called.

If you don't have an OnClose() function use class wizard to add a handler for WM_CLOSE.

MikeL
April 9th, 1999, 07:30 AM
Alternatively, you may be able to modify the
CREATESTRUCT structure in PreCreateWindow().

Oak
April 9th, 1999, 10:03 AM
Place this code at any place (but window must be already created)
It will disable ur close button.

CMenu *pSysMenu = (CMenu*)AfxGetMainWnd()->GetSystemMenu(FALSE);
pSysMenu->DeleteMenu(SC_CLOSE, MF_BYCOMMAND);
AfxGetMainWnd()->PostMessage(WM_NCACTIVATE);