Click to See Complete Forum and Search --> : Disable the close X in a dialog box


Rich Peters
May 7th, 1999, 12:07 PM
Does anyone know how to disable the close x in the upper right corner? I havent found any information on this

thanks

Rich

Howard Birkett
May 7th, 1999, 01:16 PM
You could simply override OnCancel() to do nothing.

Howard

Rich Peters
May 7th, 1999, 01:34 PM
I guess I left something out... This is a modeless dialog and OnCancel doesnt seem to get called if you click on the X. I have a busy state where a thread has to be shut down before exiting.

Mike Harnad
May 7th, 1999, 03:15 PM
Try trapping WM_CLOSE (OnClose).

cwarez
May 7th, 1999, 05:10 PM
Put in a handler for WM_CLOSE
and do not call the default base class handler.

May 7th, 1999, 10:13 PM
All replies are good. But without gray the X button, the app won't look professional. The function DrawFrameControl() may help.

xiaolong wu

May 8th, 1999, 02:00 PM
Put this into yoour dialogs OnInitDialog function...

CMenu* sysMenu = this->GetSystemMenu(FALSE);
sysMenu->EnableMenuItem(SC_CLOSE, MF_GRAYED);

Saeed R
May 9th, 1999, 10:20 PM
How about disabling the Title bar check box on the dialog property...(system menu)... so all you would have is the dialogue without anything on top

Rich Peters
May 9th, 1999, 10:54 PM
Thanks, it works like a charm...