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. Selecting contents of Edit Box

Selecting contents of Edit Box

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 1 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.
  • B Offline
    B Offline
    Bruce
    wrote on last edited by
    #1

    I am making a form-based executable with numeric edit boxes. Is there any way to make it so the contents of an edit box are selected with a single click? I want to make it easy for people to replace the contents if they're not accustomed to tabbing or double clicking, but I don't want the contents cleared or changed unless they choose to do so. I tried using OnSetFocus with a SetSel(0,-1) command, but it didn't do anything.

    A 1 Reply Last reply
    0
    • B Bruce

      I am making a form-based executable with numeric edit boxes. Is there any way to make it so the contents of an edit box are selected with a single click? I want to make it easy for people to replace the contents if they're not accustomed to tabbing or double clicking, but I don't want the contents cleared or changed unless they choose to do so. I tried using OnSetFocus with a SetSel(0,-1) command, but it didn't do anything.

      A Offline
      A Offline
      Anthony Mai
      wrote on last edited by
      #2

      Why? By default contents of edit boxes are selected (highlighted) when first focused (try tab through the edit boxes and you will see). The problem is the mouse click actually unselects it and set the cursor to where the mouse pointer is. So if you want, you may handle the WM_LBUTTONDOWN message and skip the first occurence of this message after the editbox is initially focused. But in general you should have a better solution to simplify the user interaction, rather than just a "one click select" versus "double click focus". Think smarter from a user perspective, not from a programmer perspective!

      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