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