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 not to close the Dialog Box

How not to close the Dialog Box

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
10 Posts 3 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 Offline
    E Offline
    Exceter
    wrote on last edited by
    #1

    Hi, Help me please with the following: I created an application, and added a dialog box to that, and, in the dialog box there are edit boxes, and I can't manage the following: when I press the OK Button I want to check if there are any empty edit boxes, and if there are, not to closing the dialog box go to that edit box? Thanx.

    M D 2 Replies Last reply
    0
    • E Exceter

      Hi, Help me please with the following: I created an application, and added a dialog box to that, and, in the dialog box there are edit boxes, and I can't manage the following: when I press the OK Button I want to check if there are any empty edit boxes, and if there are, not to closing the dialog box go to that edit box? Thanx.

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Are you using a class library? If you're using MFC (just guessing), you do your checks in OnOK(). If the data doesn't pass your checks, just don't call CDialog::OnOK() --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

      E 2 Replies Last reply
      0
      • M Michael Dunn

        Are you using a class library? If you're using MFC (just guessing), you do your checks in OnOK(). If the data doesn't pass your checks, just don't call CDialog::OnOK() --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

        E Offline
        E Offline
        Exceter
        wrote on last edited by
        #3

        Thanx for your quick reply. Yeah, that was really silly question. I should know that.

        1 Reply Last reply
        0
        • M Michael Dunn

          Are you using a class library? If you're using MFC (just guessing), you do your checks in OnOK(). If the data doesn't pass your checks, just don't call CDialog::OnOK() --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

          E Offline
          E Offline
          Exceter
          wrote on last edited by
          #4

          Oh, one more thing how that is done with tabbed dialog boxes? I did that in single dialog box, works fine, but in the tabbed dialog boxes i cant manage. thanx.

          M 1 Reply Last reply
          0
          • E Exceter

            Oh, one more thing how that is done with tabbed dialog boxes? I did that in single dialog box, works fine, but in the tabbed dialog boxes i cant manage. thanx.

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            Override OnQueryCancel() in your property page --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

            E 1 Reply Last reply
            0
            • M Michael Dunn

              Override OnQueryCancel() in your property page --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

              E Offline
              E Offline
              Exceter
              wrote on last edited by
              #6

              well, for Cancel button I need nothing, what I need is when the OK button pressed, to check if the Edit Box is Empty, if it is empty, not closing the dialog (Tabbed) Box, go set the Focus to that Edit Box. I managed to check the Edit, but the Dialog (tabbed) Box closes. I do not press te Cancel Button.

              D 1 Reply Last reply
              0
              • E Exceter

                Hi, Help me please with the following: I created an application, and added a dialog box to that, and, in the dialog box there are edit boxes, and I can't manage the following: when I press the OK Button I want to check if there are any empty edit boxes, and if there are, not to closing the dialog box go to that edit box? Thanx.

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

                Exceter wrote: when I press the OK Button I want to check if there are any empty edit boxes, and if there are, not to closing the dialog box go to that edit box? Do not allow the OK button to be clicked until ALL controls contain valid data. Your users will be very annoyed that the OK button is allowed to be clicked when there is invalid data; this violates the basic principles of GUI design.

                E 1 Reply Last reply
                0
                • E Exceter

                  well, for Cancel button I need nothing, what I need is when the OK button pressed, to check if the Edit Box is Empty, if it is empty, not closing the dialog (Tabbed) Box, go set the Focus to that Edit Box. I managed to check the Edit, but the Dialog (tabbed) Box closes. I do not press te Cancel Button.

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

                  You need to do validation in the page's OnKillActive() function. Returning FALSE will keep the user from switching to the other tab(s). Also, When the OK button is clicked, OnKillActive() is called first to see if it is ok to proceed. Set breakpoints in these two methods to see how things work.

                  1 Reply Last reply
                  0
                  • D David Crow

                    Exceter wrote: when I press the OK Button I want to check if there are any empty edit boxes, and if there are, not to closing the dialog box go to that edit box? Do not allow the OK button to be clicked until ALL controls contain valid data. Your users will be very annoyed that the OK button is allowed to be clicked when there is invalid data; this violates the basic principles of GUI design.

                    E Offline
                    E Offline
                    Exceter
                    wrote on last edited by
                    #9

                    How can I disallow the OK button in tabbed dialog box?

                    D 1 Reply Last reply
                    0
                    • E Exceter

                      How can I disallow the OK button in tabbed dialog box?

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

                      It was not meant to be "disallowed." See my reply about OnKillActive().

                      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