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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. edit control

edit control

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 5 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
    kumar_mk
    wrote on last edited by
    #1

    I have an Edit control in my dialog box that takes a 10 digit number, now my requirement is after entering the number in the control, i will hit the return (enter) button in the keyboard for some validation to take place. remember only with the pressing of the enter key in my keyboard, the validation should take place, i have tried handling the ON_EN_KILLFOCUS and ON_EN_CHANGE notification messages but in vain!!! i have also tried enabling the Want Return style of the edit button but still i am not able to achieve the task, pls help?? thanx in advance kumar_windows

    K E D B 4 Replies Last reply
    0
    • K kumar_mk

      I have an Edit control in my dialog box that takes a 10 digit number, now my requirement is after entering the number in the control, i will hit the return (enter) button in the keyboard for some validation to take place. remember only with the pressing of the enter key in my keyboard, the validation should take place, i have tried handling the ON_EN_KILLFOCUS and ON_EN_CHANGE notification messages but in vain!!! i have also tried enabling the Want Return style of the edit button but still i am not able to achieve the task, pls help?? thanx in advance kumar_windows

      K Offline
      K Offline
      koloporanistka
      wrote on last edited by
      #2

      You can try to put button near the edit control and make it a DEFAULT button. Then, after you insert the number and press Enter, the default button will be pressed. So you can validate the input. Nina

      1 Reply Last reply
      0
      • K kumar_mk

        I have an Edit control in my dialog box that takes a 10 digit number, now my requirement is after entering the number in the control, i will hit the return (enter) button in the keyboard for some validation to take place. remember only with the pressing of the enter key in my keyboard, the validation should take place, i have tried handling the ON_EN_KILLFOCUS and ON_EN_CHANGE notification messages but in vain!!! i have also tried enabling the Want Return style of the edit button but still i am not able to achieve the task, pls help?? thanx in advance kumar_windows

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

        Use PreTranslateMessage with VK_RETURN

        1 Reply Last reply
        0
        • K kumar_mk

          I have an Edit control in my dialog box that takes a 10 digit number, now my requirement is after entering the number in the control, i will hit the return (enter) button in the keyboard for some validation to take place. remember only with the pressing of the enter key in my keyboard, the validation should take place, i have tried handling the ON_EN_KILLFOCUS and ON_EN_CHANGE notification messages but in vain!!! i have also tried enabling the Want Return style of the edit button but still i am not able to achieve the task, pls help?? thanx in advance kumar_windows

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

          If you are simply wanting to validate the contents of the edit control when it loses focus, just handle the EN_KILLFOCUS notification. Messing around with the Enter key and/or the EN_CHANGE notification is not necessary. Now if you want the OK button disabled until a valid number is entered in the edit control, that is a different problem requiring a different answer.


          "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

          "Judge not by the eye but by the heart." - Native American Proverb

          1 Reply Last reply
          0
          • K kumar_mk

            I have an Edit control in my dialog box that takes a 10 digit number, now my requirement is after entering the number in the control, i will hit the return (enter) button in the keyboard for some validation to take place. remember only with the pressing of the enter key in my keyboard, the validation should take place, i have tried handling the ON_EN_KILLFOCUS and ON_EN_CHANGE notification messages but in vain!!! i have also tried enabling the Want Return style of the edit button but still i am not able to achieve the task, pls help?? thanx in advance kumar_windows

            B Offline
            B Offline
            bitsNbites
            wrote on last edited by
            #5

            I have noticed that the on-kill-focus is not called for cases where the focus really doesn't leave the control, for example clicking on an icon or perhaps when you press the enter key? What I have done is to force a focus change. The first statement you should have within your method called by the enter click is to set focus somewhere. See if this then calls you on-kill-focus method for the edit box.

            If only I had more time!

            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