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.
Printable View
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.
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.
Alternatively, you may be able to modify the
CREATESTRUCT structure in PreCreateWindow().
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);