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. system menu on dialog

system menu on dialog

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
17 Posts 5 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.
  • E Eytukan

    Just handle the cancel button click event.

    void CYourDlg::OnBnClickedCancel()
    {
    AfxMessageBox("Don't close!");
    }


    Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

    G Offline
    G Offline
    GuyM
    wrote on last edited by
    #4

    in the system-menu, not the Cancel button ... :) Here's the code:

    void CYourDlg::OnClose()
    {
    AfxMessageBox("Don't close!");
    }

    ... and don't forget to add the ON_WM_CLOSE() macro in the dialog's message-map.

    E 2 Replies Last reply
    0
    • G GuyM

      in the system-menu, not the Cancel button ... :) Here's the code:

      void CYourDlg::OnClose()
      {
      AfxMessageBox("Don't close!");
      }

      ... and don't forget to add the ON_WM_CLOSE() macro in the dialog's message-map.

      E Offline
      E Offline
      Eytukan
      wrote on last edited by
      #5

      Hey that still works with System menu's [x]. Did you check that? but yes mentioning "WM_CLOSE" is required! ;)


      Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

      G R 2 Replies Last reply
      0
      • E Eytukan

        Hey that still works with System menu's [x]. Did you check that? but yes mentioning "WM_CLOSE" is required! ;)


        Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

        G Offline
        G Offline
        GuyM
        wrote on last edited by
        #6

        :omg: Hey, I just checked it, and you know what ? You're absolutely right !!! :omg: Sorry, my bad :doh: You rule !! Guy.

        1 Reply Last reply
        0
        • G GuyM

          in the system-menu, not the Cancel button ... :) Here's the code:

          void CYourDlg::OnClose()
          {
          AfxMessageBox("Don't close!");
          }

          ... and don't forget to add the ON_WM_CLOSE() macro in the dialog's message-map.

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #7

          Actually I was searching for OnCancel but it's not there with 7.1 compiler. VS6.0 displays the cancel event handler as "::OnCancel". but in 7.1 it's generating OnBnClickedCancel.


          Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

          1 Reply Last reply
          0
          • E Eytukan

            Just handle the cancel button click event.

            void CYourDlg::OnBnClickedCancel()
            {
            AfxMessageBox("Don't close!");
            }


            Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #8

            Why would you suggest that? If you write your code in OnCancel(), then it would be obviously executed when the Esc key is pressed and also when the cancel button is pressed. Handling WM_CLOSE is the right way.

            E 1 Reply Last reply
            0
            • D deeps_cute

              how to display messagebox when click system menu(X) on dialogbox. Thank to all

              Arise Awake Stop Not Till ur Goal is Reached.

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #9

              Handle WM_CLOSE message.

              1 Reply Last reply
              0
              • E Eytukan

                Hey that still works with System menu's [x]. Did you check that? but yes mentioning "WM_CLOSE" is required! ;)


                Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #10

                VuNic wrote:

                Hey that still works with System menu's [x]. Did you check that? but yes mentioning "WM_CLOSE" is required!

                What do you mean by "mentioning WM_CLOSE is required"?

                E 1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  VuNic wrote:

                  Hey that still works with System menu's [x]. Did you check that? but yes mentioning "WM_CLOSE" is required!

                  What do you mean by "mentioning WM_CLOSE is required"?

                  E Offline
                  E Offline
                  Eytukan
                  wrote on last edited by
                  #11

                  close!. ;)


                  Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

                  1 Reply Last reply
                  0
                  • R Rajesh R Subramanian

                    Why would you suggest that? If you write your code in OnCancel(), then it would be obviously executed when the Esc key is pressed and also when the cancel button is pressed. Handling WM_CLOSE is the right way.

                    E Offline
                    E Offline
                    Eytukan
                    wrote on last edited by
                    #12

                    Yeah, nobody would want their application to get closed with an Esc. I really wonder why MFC has it that way :unsure:. So handling WM_CLOSE is the best way. Thanks for stressing that one out. :-D :beer:


                    Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

                    R 1 Reply Last reply
                    0
                    • E Eytukan

                      Yeah, nobody would want their application to get closed with an Esc. I really wonder why MFC has it that way :unsure:. So handling WM_CLOSE is the best way. Thanks for stressing that one out. :-D :beer:


                      Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

                      R Offline
                      R Offline
                      Rajesh R Subramanian
                      wrote on last edited by
                      #13

                      VuNic wrote:

                      Yeah, nobody would want their application to get closed with an Esc.

                      You assume things.

                      VuNic wrote:

                      I really wonder why MFC has it that way :unsure:. So handling WM_CLOSE is the best way.

                      That is by design. Pressing the Esc key in a dialog based app will execute some extremely old windows code. As a developer, you are not supposed to develop complex applications which is dialog based. As a user, he would always expect a dialog to get dismissed when the Esc key is pressed. For instance, if you right click on the desktop and choose properties, you will expect the properties window to get dismissed on pressing Esc. I am working on my first article, and I have elaborated on this dialog box closing glitch issue more clearly.

                      E 1 Reply Last reply
                      0
                      • R Rajesh R Subramanian

                        VuNic wrote:

                        Yeah, nobody would want their application to get closed with an Esc.

                        You assume things.

                        VuNic wrote:

                        I really wonder why MFC has it that way :unsure:. So handling WM_CLOSE is the best way.

                        That is by design. Pressing the Esc key in a dialog based app will execute some extremely old windows code. As a developer, you are not supposed to develop complex applications which is dialog based. As a user, he would always expect a dialog to get dismissed when the Esc key is pressed. For instance, if you right click on the desktop and choose properties, you will expect the properties window to get dismissed on pressing Esc. I am working on my first article, and I have elaborated on this dialog box closing glitch issue more clearly.

                        E Offline
                        E Offline
                        Eytukan
                        wrote on last edited by
                        #14

                        brahmma wrote:

                        and I have elaborated on this dialog box closing glitch issue more clearly.

                        Wow.. waiting for it :-D. Bram, do you work with MDI-DOC/View thing?


                        Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

                        R 1 Reply Last reply
                        0
                        • E Eytukan

                          brahmma wrote:

                          and I have elaborated on this dialog box closing glitch issue more clearly.

                          Wow.. waiting for it :-D. Bram, do you work with MDI-DOC/View thing?


                          Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

                          R Offline
                          R Offline
                          Rajesh R Subramanian
                          wrote on last edited by
                          #15

                          I stopped working with MFC quite a long time ago. Currently I am working on Windows Mobile and embedded C (Dynamic C). I have worked with MDI applications too, but for some reason I love dialog based applications and hooking and spying out stuff from within a DLL.

                          E 1 Reply Last reply
                          0
                          • R Rajesh R Subramanian

                            I stopped working with MFC quite a long time ago. Currently I am working on Windows Mobile and embedded C (Dynamic C). I have worked with MDI applications too, but for some reason I love dialog based applications and hooking and spying out stuff from within a DLL.

                            E Offline
                            E Offline
                            Eytukan
                            wrote on last edited by
                            #16

                            Yeah me too, in general I hate UIs to a good extent. :sigh:


                            Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

                            1 Reply Last reply
                            0
                            • D deeps_cute

                              how to display messagebox when click system menu(X) on dialogbox. Thank to all

                              Arise Awake Stop Not Till ur Goal is Reached.

                              T Offline
                              T Offline
                              ThatsAlok
                              wrote on last edited by
                              #17

                              deeps_cute wrote:

                              how to display messagebox when click system menu(X) on dialogbox.

                              handle oncancel function

                              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                              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