Get rid of xlose box in control box

  • Thread starter Thread starter Larry Hilley
  • Start date Start date
L

Larry Hilley

Hi, I have a form that I do not want the user to be able to close, but I do
want the user to be able to minimize the form.

Any ideas?

Larry Hilley
 
Hi, I have a form that I do not want the user to be able to close, but I do
want the user to be able to minimize the form.

Larry,

Your use of the term "form" may imply that you're using WinForms, so
this reply may not apply (directly).

For a Win32/MFC application, you can disable the close button by doing
something like this:

Call the following in OnInitDialog (WM_INITDIALOG):

::EnableMenuItem( ::GetSystemMenu( m_hWnd, FALSE ),
SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED );

Prevent the accelerator (Alt+F4):

void CAboutDlg::OnSysCommand(UINT nID, LONG lParam )
{
if ( ( nID & 0x0FFF0 ) != SC_CLOSE )
{
CDialog::OnSysCommand( nID, lParam );
}
}

Dave
 
Back
Top