CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 1999
    Posts
    33

    Disable the close X in a dialog box

    Does anyone know how to disable the close x in the upper right corner? I havent found any information on this

    thanks

    Rich


  2. #2
    Join Date
    May 1999
    Posts
    17

    Re: Disable the close X in a dialog box

    You could simply override OnCancel() to do nothing.

    Howard


  3. #3
    Join Date
    Apr 1999
    Posts
    33

    Re: Disable the close X in a dialog box

    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.




  4. #4
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Disable the close X in a dialog box

    Try trapping WM_CLOSE (OnClose).

    Gort...Klaatu, Barada Nikto!

  5. #5
    Join Date
    May 1999
    Posts
    4

    Re: Disable the close X in a dialog box

    Put in a handler for WM_CLOSE
    and do not call the default base class handler.


  6. #6
    Guest

    Re: Disable the close X in a dialog box

    All replies are good. But without gray the X button, the app won't look professional. The function DrawFrameControl() may help.

    xiaolong wu


  7. #7
    Guest

    Re: Disable the close X in a dialog box

    Put this into yoour dialogs OnInitDialog function...

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


  8. #8
    Join Date
    May 1999
    Posts
    78

    Re: Disable the close X in a dialog box

    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


  9. #9
    Join Date
    Apr 1999
    Posts
    33

    Re: Disable the close X in a dialog box

    Thanks, it works like a charm...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured