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. Way to use both EN_CHANGE and EN_KILLFOCUS

Way to use both EN_CHANGE and EN_KILLFOCUS

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
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.
  • Z Offline
    Z Offline
    zxc89
    wrote on last edited by
    #1

    Is there a way to use both EN_CHANGE & EN_KILLFOCUS for edit controls(dynamic edit controls) I need to use EN_KILLFOCUS bcoz when the focus is changed from edit control to another edit control,the value entered should be validated. and now if i change a value in the edit control and try to close the application,the value should be saved!! So,the problem is that when i try to close the application,the focus changes,thus calling EN_KILLFOCUS.. So plz help me whether both can be used at the same time?

    C D 2 Replies Last reply
    0
    • Z zxc89

      Is there a way to use both EN_CHANGE & EN_KILLFOCUS for edit controls(dynamic edit controls) I need to use EN_KILLFOCUS bcoz when the focus is changed from edit control to another edit control,the value entered should be validated. and now if i change a value in the edit control and try to close the application,the value should be saved!! So,the problem is that when i try to close the application,the focus changes,thus calling EN_KILLFOCUS.. So plz help me whether both can be used at the same time?

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      These are two different events and they are not used 'at the same time'. EN_CHANGE will be fired each time you change something in the edit (each time you press a key, it will be fired) and EN_KILLFOCUS is fired only when the control looses the focus. So, why do you see a problem there ?

      Z 1 Reply Last reply
      0
      • C Cedric Moonen

        These are two different events and they are not used 'at the same time'. EN_CHANGE will be fired each time you change something in the edit (each time you press a key, it will be fired) and EN_KILLFOCUS is fired only when the control looses the focus. So, why do you see a problem there ?

        Z Offline
        Z Offline
        zxc89
        wrote on last edited by
        #3

        See, the problem is that when there is a change in the edit box and then if i try to close my application(Either by File->Exit or Alt+F4),both EN_CHANAGE and EN_KILLFOCUS fires. I use EN_KILLFOCUS to validate the entered text/value in edit control when there is a change focus. So when i exit my application after changing the value,it should prompt for SAVING,it does but it also handles the EN_KILLFOCUS when a invalid value is entered.

        N 1 Reply Last reply
        0
        • Z zxc89

          See, the problem is that when there is a change in the edit box and then if i try to close my application(Either by File->Exit or Alt+F4),both EN_CHANAGE and EN_KILLFOCUS fires. I use EN_KILLFOCUS to validate the entered text/value in edit control when there is a change focus. So when i exit my application after changing the value,it should prompt for SAVING,it does but it also handles the EN_KILLFOCUS when a invalid value is entered.

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          zxc89 wrote:

          I use EN_KILLFOCUS to validate the entered text/value in edit control when there is a change focus. So when i exit my application after changing the value,it should prompt for SAVING,it does but it also handles the EN_KILLFOCUS when a invalid value is entered.

          Why don't you try One Time Validation? This means validate before you save the data. Personally I don't like message boxes to come up when I press tab saying "You have to enter proper data". Lol it's very irritating. X|


          Nibu thomas Software Developer Faqs by Michael dunn

          Z 1 Reply Last reply
          0
          • N Nibu babu thomas

            zxc89 wrote:

            I use EN_KILLFOCUS to validate the entered text/value in edit control when there is a change focus. So when i exit my application after changing the value,it should prompt for SAVING,it does but it also handles the EN_KILLFOCUS when a invalid value is entered.

            Why don't you try One Time Validation? This means validate before you save the data. Personally I don't like message boxes to come up when I press tab saying "You have to enter proper data". Lol it's very irritating. X|


            Nibu thomas Software Developer Faqs by Michael dunn

            Z Offline
            Z Offline
            zxc89
            wrote on last edited by
            #5

            but my requirement is like that..Any more ideas???

            1 Reply Last reply
            0
            • Z zxc89

              Is there a way to use both EN_CHANGE & EN_KILLFOCUS for edit controls(dynamic edit controls) I need to use EN_KILLFOCUS bcoz when the focus is changed from edit control to another edit control,the value entered should be validated. and now if i change a value in the edit control and try to close the application,the value should be saved!! So,the problem is that when i try to close the application,the focus changes,thus calling EN_KILLFOCUS.. So plz help me whether both can be used at the same time?

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

              Don't do the validation during EN_KILLFOCUS. Unless the validation is time consuming, do it with each EN_CHANGE.


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "We will be known forever by the tracks we leave." - Native American Proverb

              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