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. How can I show only Cancel button on Messagebox

How can I show only Cancel button on Messagebox

Scheduled Pinned Locked Moved C / C++ / MFC
question
14 Posts 3 Posters 1 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.
  • S sheshidar

    Hi All, I am trying to show a message box with only one button"Cancel".

    int MessageBox( HWND hWnd,
    LPCTSTR lpText,
    LPCTSTR lpCaption,
    UINT uType
    );

    in uType we can give MB_OK or MB_OKCANCEL. But I want to have only one button on messagebox ie "Cancel". how can I get this. Thanks .. Sheshidar

    S Offline
    S Offline
    Saurabh Garg
    wrote on last edited by
    #3

    I don't think it is possible with MessabeBox. You can simple create your own dialog and add a single cancel button. -Saurabh

    S 1 Reply Last reply
    0
    • H Hamid Taebi

      You can use of MB_OK.

      S Offline
      S Offline
      Saurabh Garg
      wrote on last edited by
      #4

      Yes but MB_OK is not going to give him Cancel button. -Saurabh

      H 1 Reply Last reply
      0
      • S Saurabh Garg

        I don't think it is possible with MessabeBox. You can simple create your own dialog and add a single cancel button. -Saurabh

        S Offline
        S Offline
        sheshidar
        wrote on last edited by
        #5

        Thanks Guys, I created a new dialog to work with cancel button. I wanted to try with messagebox only. Any way thanks for ur replies.

        S 1 Reply Last reply
        0
        • S sheshidar

          Thanks Guys, I created a new dialog to work with cancel button. I wanted to try with messagebox only. Any way thanks for ur replies.

          S Offline
          S Offline
          Saurabh Garg
          wrote on last edited by
          #6

          You are welcome. Btw you may want to check out XMessageBox - A reverse-engineered MessageBox() [^]. It has more functionality then standard MessageBox and also allows custom buttons. -Saurabh

          1 Reply Last reply
          0
          • S Saurabh Garg

            Yes but MB_OK is not going to give him Cancel button. -Saurabh

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #7

            I dont think we have MB_CANCEL but I think he can changes title of button.

            S 1 Reply Last reply
            0
            • H Hamid Taebi

              I dont think we have MB_CANCEL but I think he can changes title of button.

              S Offline
              S Offline
              Saurabh Garg
              wrote on last edited by
              #8

              After reading MSDN documentation I couldn't find anything. Do you know how to do that? -Saurabh

              H 1 Reply Last reply
              0
              • S Saurabh Garg

                After reading MSDN documentation I couldn't find anything. Do you know how to do that? -Saurabh

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #9

                You can get a handle to a messagebox window and then you can change text of it.

                S 1 Reply Last reply
                0
                • H Hamid Taebi

                  You can get a handle to a messagebox window and then you can change text of it.

                  S Offline
                  S Offline
                  Saurabh Garg
                  wrote on last edited by
                  #10

                  MessageBox is a modal window so it blocks the calling thread. So once you call MessageBox then unless you dismiss it nothing else can be done. -Saurabh

                  H 1 Reply Last reply
                  0
                  • S Saurabh Garg

                    MessageBox is a modal window so it blocks the calling thread. So once you call MessageBox then unless you dismiss it nothing else can be done. -Saurabh

                    H Offline
                    H Offline
                    Hamid Taebi
                    wrote on last edited by
                    #11

                    I saw my files it was on the C#.

                    S 1 Reply Last reply
                    0
                    • H Hamid Taebi

                      I saw my files it was on the C#.

                      S Offline
                      S Offline
                      Saurabh Garg
                      wrote on last edited by
                      #12

                      I hate to do this but it is not going to work in C# as well. System.Windows.Forms.MessageBox mimics MessageBox in windows. So there is no option to use just the Cancel button. -Saurabh

                      H 1 Reply Last reply
                      0
                      • S Saurabh Garg

                        I hate to do this but it is not going to work in C# as well. System.Windows.Forms.MessageBox mimics MessageBox in windows. So there is no option to use just the Cancel button. -Saurabh

                        H Offline
                        H Offline
                        Hamid Taebi
                        wrote on last edited by
                        #13

                        Saurabh.Garg wrote:

                        I hate to do this but it is not going to work in C#

                        Why c# is good I think its easy to learn anyway maybe you like to see Dissecting the MessageBox[^].

                        S 1 Reply Last reply
                        0
                        • H Hamid Taebi

                          Saurabh.Garg wrote:

                          I hate to do this but it is not going to work in C#

                          Why c# is good I think its easy to learn anyway maybe you like to see Dissecting the MessageBox[^].

                          S Offline
                          S Offline
                          Saurabh Garg
                          wrote on last edited by
                          #14

                          I never asked why C# is good!!! We were talking about MessageBox. I have seen that article and it create a new class for doing custom stuff. It has got nothing to do with MessageBox WinAPI provides. -Saurabh

                          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