CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2001
    Location
    USA
    Posts
    298

    Making system menu go away

    I have an SDI Doc/View application with CFormView as the base class. I want the close box (System Menu) to not be available to the user. The System Menu property for the main form has no effect on this for some reason. Is there something in the Doc/View classes that overrides the property box, or maybe I'm looking at the wrong thing?

    Thanks

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Making system menu go away

    Override your CMainFrame's PreCreateWindow and remove the style
    Code:
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    	cs.style &= ~WS_SYSMENU; 
    	return CFrameWnd::PreCreateWindow(cs);
    }

  3. #3
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Making system menu go away

    But of course, even without the system menu, the user can still use accelerators like alt-F4 to close the program.

    If you want the program to be "uncloseable" you need to do more work than simply removing the system menu.

    Mike

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Making system menu go away

    I hope you have a very good reason for disabling it. Every time I encounter an application that disable this and that for some obscure reason it makes me furious.

    I like to work like I'm used to and expect every application to behave like a normal Windows application (or being un-installed and replaced with something else). I don't want the minimize button to be disabled, I don't want the window to be on top of everything, I don't want the window to force itself into fullscreen and so on...
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Jun 2001
    Location
    USA
    Posts
    298

    Re: Making system menu go away

    Quote Originally Posted by GCDEF View Post
    Override your CMainFrame's PreCreateWindow and remove the style
    Code:
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    	cs.style &= ~WS_SYSMENU; 
    	return CFrameWnd::PreCreateWindow(cs);
    }
    Thank you, that worked.

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