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. X button in the Dialog MFC vc++

X button in the Dialog MFC vc++

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
6 Posts 4 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.
  • M Offline
    M Offline
    Member_14575556
    wrote on last edited by
    #1

    I trying to put some custom functionality when x button is clicked for a specific dialog. There is no cancel button in this dialog. What would be the best way to do this? Thank you.

    V M D 3 Replies Last reply
    0
    • M Member_14575556

      I trying to put some custom functionality when x button is clicked for a specific dialog. There is no cancel button in this dialog. What would be the best way to do this? Thank you.

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      Have a look at [visual studio - Close Button on Title Bar in MFC - Stack Overflow](https://stackoverflow.com/questions/1163484/close-button-on-title-bar-in-mfc)

      M 1 Reply Last reply
      0
      • M Member_14575556

        I trying to put some custom functionality when x button is clicked for a specific dialog. There is no cancel button in this dialog. What would be the best way to do this? Thank you.

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        Can you handle the WM_CLOSE message ?

        I'd rather be phishing!

        1 Reply Last reply
        0
        • M Member_14575556

          I trying to put some custom functionality when x button is clicked for a specific dialog. There is no cancel button in this dialog. What would be the best way to do this? Thank you.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Override the dialog's OnCancel() method.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          1 Reply Last reply
          0
          • V Victor Nijegorodov

            Have a look at [visual studio - Close Button on Title Bar in MFC - Stack Overflow](https://stackoverflow.com/questions/1163484/close-button-on-title-bar-in-mfc)

            M Offline
            M Offline
            Member_14575556
            wrote on last edited by
            #5

            Thanks, this is exactly what I wanted. :)

            D 1 Reply Last reply
            0
            • M Member_14575556

              Thanks, this is exactly what I wanted. :)

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

              While OnClose() does get called when dismissing the dialog using the X or Alt+F4, it will not get called when dismissing the dialog using Esc or clicking the Cancel button (if one is present). This may not be an issue for your specific dialog, however.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              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