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. EN_KILLFOCUS AfxMessageBox [Moved]

EN_KILLFOCUS AfxMessageBox [Moved]

Scheduled Pinned Locked Moved C / C++ / MFC
help
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.
  • S Offline
    S Offline
    sharda bhagwatkar
    wrote on last edited by
    #1

    I have a dialog box on which some Edit boxes are there. For validation of values in edit boxes, i have handled EN_KILLFOCUS. When EN_KILLFOCUS is called, value in edit box is validated. If validation fails, then AfxMessageBox is displayed "Input value is in correct". The problem is when i press ALT+TAB and switch to another application, the Afxmessagebox is re-displayed because EN_KILLFOCUS is called again. Please let me know any solution to be handled in EN_KILLFOCUS so that Afxmessagbox is not displayed. Thanking you in advance. Regards, Sharda.

    modified on Friday, July 24, 2009 12:41 AM

    C K A 3 Replies Last reply
    0
    • S sharda bhagwatkar

      I have a dialog box on which some Edit boxes are there. For validation of values in edit boxes, i have handled EN_KILLFOCUS. When EN_KILLFOCUS is called, value in edit box is validated. If validation fails, then AfxMessageBox is displayed "Input value is in correct". The problem is when i press ALT+TAB and switch to another application, the Afxmessagebox is re-displayed because EN_KILLFOCUS is called again. Please let me know any solution to be handled in EN_KILLFOCUS so that Afxmessagbox is not displayed. Thanking you in advance. Regards, Sharda.

      modified on Friday, July 24, 2009 12:41 AM

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Generally it is not a good idea to validate user input on focus loss, for example see here[^]. In the old times when i tried to do the same i ran into all kinds or troubles myself. If you can i recommend rethinking your validation system.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

      S 1 Reply Last reply
      0
      • S sharda bhagwatkar

        I have a dialog box on which some Edit boxes are there. For validation of values in edit boxes, i have handled EN_KILLFOCUS. When EN_KILLFOCUS is called, value in edit box is validated. If validation fails, then AfxMessageBox is displayed "Input value is in correct". The problem is when i press ALT+TAB and switch to another application, the Afxmessagebox is re-displayed because EN_KILLFOCUS is called again. Please let me know any solution to be handled in EN_KILLFOCUS so that Afxmessagbox is not displayed. Thanking you in advance. Regards, Sharda.

        modified on Friday, July 24, 2009 12:41 AM

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

        validating data is done in the OnOk(). If the data is invalid, dieplay a message and DONT close the dialog. (I am setting the focus to the invalid data to help)

        Press F1 for help or google it. Greetings from Germany

        1 Reply Last reply
        0
        • C Code o mat

          Generally it is not a good idea to validate user input on focus loss, for example see here[^]. In the old times when i tried to do the same i ran into all kinds or troubles myself. If you can i recommend rethinking your validation system.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

          S Offline
          S Offline
          sharda bhagwatkar
          wrote on last edited by
          #4

          Yes your right...I also know it that validation in kill focus is not a good idea....but still i have to do it because its an requirement... Please suggest be some idea to handle this situation....

          C 1 Reply Last reply
          0
          • S sharda bhagwatkar

            Yes your right...I also know it that validation in kill focus is not a good idea....but still i have to do it because its an requirement... Please suggest be some idea to handle this situation....

            C Offline
            C Offline
            Code o mat
            wrote on last edited by
            #5

            I guess if it was easy to solve it wouldn't be a problem to validate on focus loss. You could try to check if the window who gets the focus belongs to your application or not, or maybe check if your aplication is the active application on the syatem or not and not display the message if it is not. Do these make any sense? How about a different aproach? Don't display a message box but change the errorous edit field's background color to red for example, and maybe have a static field or such placed somewhere on your dialog that explains to the user what is wrong with the edit field, maybe show the error message in a tooltip when the user points his mouse at the edit field. Or is the message box itself also a requirement?

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

            1 Reply Last reply
            0
            • S sharda bhagwatkar

              I have a dialog box on which some Edit boxes are there. For validation of values in edit boxes, i have handled EN_KILLFOCUS. When EN_KILLFOCUS is called, value in edit box is validated. If validation fails, then AfxMessageBox is displayed "Input value is in correct". The problem is when i press ALT+TAB and switch to another application, the Afxmessagebox is re-displayed because EN_KILLFOCUS is called again. Please let me know any solution to be handled in EN_KILLFOCUS so that Afxmessagbox is not displayed. Thanking you in advance. Regards, Sharda.

              modified on Friday, July 24, 2009 12:41 AM

              A Offline
              A Offline
              Adam Roderick J
              wrote on last edited by
              #6

              what u want to validate?

              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