Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Disable window close [X] button

Disable window close [X] button

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David Chamberlain
    wrote on last edited by
    #1

    button so it won't accidently be hit, but I can't locate an easy way to do it. I did Google and found a couple of question/answer pages, but the solutions didn't work. They dealt with changing the system menu. Isn't there a style element or something easy? As I said, any help will be most appreciated. Thanks, Dave
    "You can say that again." -- Dept. of Redundancy Dept.

    U V J 3 Replies Last reply
    0
    • D David Chamberlain

      button so it won't accidently be hit, but I can't locate an easy way to do it. I did Google and found a couple of question/answer pages, but the solutions didn't work. They dealt with changing the system menu. Isn't there a style element or something easy? As I said, any help will be most appreciated. Thanks, Dave
      "You can say that again." -- Dept. of Redundancy Dept.

      U Offline
      U Offline
      User 423850
      wrote on last edited by
      #2

      do it by Calling SetWindowLong(GWL_STYLE) Thanx TAKE CARE

      D 1 Reply Last reply
      0
      • U User 423850

        do it by Calling SetWindowLong(GWL_STYLE) Thanx TAKE CARE

        D Offline
        D Offline
        David Chamberlain
        wrote on last edited by
        #3

        SetWindowLong? Thanks. What value should I use to disable the close button then? Dave "You can say that again." -- Dept. of Redundancy Dept.

        1 Reply Last reply
        0
        • D David Chamberlain

          button so it won't accidently be hit, but I can't locate an easy way to do it. I did Google and found a couple of question/answer pages, but the solutions didn't work. They dealt with changing the system menu. Isn't there a style element or something easy? As I said, any help will be most appreciated. Thanks, Dave
          "You can say that again." -- Dept. of Redundancy Dept.

          V Offline
          V Offline
          valikac
          wrote on last edited by
          #4

          One solution is EnableMenuItem(). GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE, MF_DISABLED); Kuphryn

          D 1 Reply Last reply
          0
          • D David Chamberlain

            button so it won't accidently be hit, but I can't locate an easy way to do it. I did Google and found a couple of question/answer pages, but the solutions didn't work. They dealt with changing the system menu. Isn't there a style element or something easy? As I said, any help will be most appreciated. Thanks, Dave
            "You can say that again." -- Dept. of Redundancy Dept.

            J Offline
            J Offline
            jason99
            wrote on last edited by
            #5

            take a look at my homepage under: http://www.code-diary.com/HTML/Diary/0001.htm greets, Jason

            1 Reply Last reply
            0
            • V valikac

              One solution is EnableMenuItem(). GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE, MF_DISABLED); Kuphryn

              D Offline
              D Offline
              David Chamberlain
              wrote on last edited by
              #6

              The problem I have with this approach is that as a child window, there is no system menu for it, and I get an unhandled exception. This is when I put these statements in the OnCreate handler of the child window. When I put this in for the main frame, then indeed it does disable the close, but for the main window, not for the child. Thanks, Dave "You can say that again." -- Dept. of Redundancy Dept.

              J B 2 Replies Last reply
              0
              • D David Chamberlain

                The problem I have with this approach is that as a child window, there is no system menu for it, and I get an unhandled exception. This is when I put these statements in the OnCreate handler of the child window. When I put this in for the main frame, then indeed it does disable the close, but for the main window, not for the child. Thanks, Dave "You can say that again." -- Dept. of Redundancy Dept.

                J Offline
                J Offline
                John M Drescher
                wrote on last edited by
                #7

                That should work anyways. See the doc for CWnd::GetSystemMenu. CWnd::GetSystemMenu CMenu* GetSystemMenu( BOOL bRevert ) const; Return Value Identifies a copy of the Control menu if bRevert is FALSE. If bRevert is TRUE, the return value is undefined. The returned pointer may be temporary and should not be stored for later use. Parameters bRevert Specifies the action to be taken. If bRevert is FALSE, GetSystemMenu returns a handle to a copy of the Control menu currently in use. This copy is initially identical to the Control menu but can be modified. If bRevert is TRUE, GetSystemMenu resets the Control menu back to the default state. The previous, possibly modified, Control menu, if any, is destroyed. The return value is undefined in this case. Remarks Allows the application to access the Control menu for copying and modification. Any window that does not use GetSystemMenu to make its own copy of the Control menu receives the standard Control menu. The pointer returned by the GetSystemMenu member function can be used with the CMenu::AppendMenu, CMenu::InsertMenu, or CMenu::ModifyMenu functions to change the Control menu. The Control menu initially contains items identified with various ID values such as SC_CLOSE, SC_MOVE, and SC_SIZE. Items on the Control menu generate WM_SYSCOMMAND messages. All predefined Control-menu items have ID numbers greater than 0xF000. If an application adds items to the Control menu, it should use ID numbers less than F000. Windows may automatically dim items on the standard Control menu. CWnd can carry out its own checking or dimming by responding to the WM_INITMENU messages, which are sent before any menu is displayed. John

                1 Reply Last reply
                0
                • D David Chamberlain

                  The problem I have with this approach is that as a child window, there is no system menu for it, and I get an unhandled exception. This is when I put these statements in the OnCreate handler of the child window. When I put this in for the main frame, then indeed it does disable the close, but for the main window, not for the child. Thanks, Dave "You can say that again." -- Dept. of Redundancy Dept.

                  B Offline
                  B Offline
                  Bob Stanneveld
                  wrote on last edited by
                  #8

                  You should be able to create a system menu. In the PreCreate() function add the style for the system menu, then disable the clost button which was explained by the other users. hope this helps (I'm not sure it will though :-O)

                  A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups