Disable the close button on a dialog box

I would like to know how we can disable the close button ( X ) on a dialog box.

NeoMind
NeoMindAsked:
Who is Participating?
 
manojbkumarConnect With a Mentor Commented:
In OnInitDilaog() add the follwing code

CMenu* pSysMenu = GetSystemMenu(FALSE);
     if (pSysMenu != NULL)
     {
          pSysMenu->RemoveMenu(SC_CLOSE,MF_BYCOMMAND);
     }
0
 
abdo81Commented:
Hi
Add this function
void CMyDlg::OnClose()
{
     return;
}
Bye
0
 
aphillipsConnect With a Mentor Commented:
Simply unchecking "System menu" on page 2 of the Dialog Properties in the dialog editor removes the checkbox.  This also removes minimize and maximize but very few dialogs have those.
0
All Courses

From novice to tech pro — start learning today.