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. Adding third choice to OK and CANCEL buttons in dialog window

Adding third choice to OK and CANCEL buttons in dialog window

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
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.
  • K Offline
    K Offline
    Kwanalouie
    wrote on last edited by
    #1

    Using Visual C++ 6.0 MFC in SDI application I created a dialog window. After the user enters data, he can select OK or CANCEL and the window automatically closes. I wanted to add a button called "TEST" to this same dialog. When the user clicks on the "TEST" button, I want to automatically close this dialog window just as it happens when he clicks OK or CANCEL. But I don't know how to set things up to do that. Thanks!

    J H 2 Replies Last reply
    0
    • K Kwanalouie

      Using Visual C++ 6.0 MFC in SDI application I created a dialog window. After the user enters data, he can select OK or CANCEL and the window automatically closes. I wanted to add a button called "TEST" to this same dialog. When the user clicks on the "TEST" button, I want to automatically close this dialog window just as it happens when he clicks OK or CANCEL. But I don't know how to set things up to do that. Thanks!

      J Offline
      J Offline
      Jijo Raj
      wrote on last edited by
      #2

      In your test button handler call

      CDialog::OnOK();

      Then your dialog will be closed automatically. :) Actually the CDialog::OnOK() calls UpdateData() to update data from controls to member variables and calls EndDialog() to close the dialog. Regards, Jijo.

      _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

      K N 2 Replies Last reply
      0
      • J Jijo Raj

        In your test button handler call

        CDialog::OnOK();

        Then your dialog will be closed automatically. :) Actually the CDialog::OnOK() calls UpdateData() to update data from controls to member variables and calls EndDialog() to close the dialog. Regards, Jijo.

        _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

        K Offline
        K Offline
        Kwanalouie
        wrote on last edited by
        #3

        Thanks a lot. That was incredibly simple! Thanks again!

        1 Reply Last reply
        0
        • J Jijo Raj

          In your test button handler call

          CDialog::OnOK();

          Then your dialog will be closed automatically. :) Actually the CDialog::OnOK() calls UpdateData() to update data from controls to member variables and calls EndDialog() to close the dialog. Regards, Jijo.

          _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

          N Offline
          N Offline
          Nelek
          wrote on last edited by
          #4

          or CDialog::OnCancel if the datas don't have to be saved :P

          Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.

          J 1 Reply Last reply
          0
          • N Nelek

            or CDialog::OnCancel if the datas don't have to be saved :P

            Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.

            J Offline
            J Offline
            Jijo Raj
            wrote on last edited by
            #5

            Very true. :laugh: Regards, Jijo.

            _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

            1 Reply Last reply
            0
            • K Kwanalouie

              Using Visual C++ 6.0 MFC in SDI application I created a dialog window. After the user enters data, he can select OK or CANCEL and the window automatically closes. I wanted to add a button called "TEST" to this same dialog. When the user clicks on the "TEST" button, I want to automatically close this dialog window just as it happens when he clicks OK or CANCEL. But I don't know how to set things up to do that. Thanks!

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

              Well you can insert a button to your dialog box and insert OnOK() or EndDialog() on this button.

              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