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. Editbox Validation when hitting enter

Editbox Validation when hitting enter

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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.
  • S Offline
    S Offline
    Steve The Plant
    wrote on last edited by
    #1

    Hi! How do I make an edit box only validate it's contents when hitting the enter key? The edit box is attached to a variable, and I only want the variable to get updated when I hit enter. Something that's not necessary, but a "nice to have" would be doing the same thing for the tab key. Besides doing the validation, it would also tab over to the next control. Steve

    C L 2 Replies Last reply
    0
    • S Steve The Plant

      Hi! How do I make an edit box only validate it's contents when hitting the enter key? The edit box is attached to a variable, and I only want the variable to get updated when I hit enter. Something that's not necessary, but a "nice to have" would be doing the same thing for the tab key. Besides doing the validation, it would also tab over to the next control. Steve

      C Offline
      C Offline
      Carlos Antollini
      wrote on last edited by
      #2

      You need to use the OnKeyDown. When you detect the Enter, you can validate the Edit. Cheers!!! Carlos Antollini.

      1 Reply Last reply
      0
      • S Steve The Plant

        Hi! How do I make an edit box only validate it's contents when hitting the enter key? The edit box is attached to a variable, and I only want the variable to get updated when I hit enter. Something that's not necessary, but a "nice to have" would be doing the same thing for the tab key. Besides doing the validation, it would also tab over to the next control. Steve

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The usual way of doing this is to handle validation in the OnKillFocus method call for that object. Then, hitting Enter (which will submit the dialog if the edit control is on a dialog) or hitting Tab (which will go to the next field in the tab order if if the edit control is on a dialog) will both kick-off that event. If you're rolling your own interface in a non-dialog setting, you should be subclassing the parent window to pre process all the messages that come through your main window proc, and that would be where you would do Enter and Tab key handling (and other key for that matter).

        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