Select Text.. What am I doing wrong

Started by Martin Francom, December 03, 2010, 05:33:01 PM

Previous topic - Next topic

Martin Francom

I have a form and on that form is a number of TextBox controls.  I have set the property "SelText"  to TRUE.   When I run the form the contents of the TextBox control will be "selected" if I TAB to the control but if I use my mouse and click on the control the contents are not "selected".

Is this how "SelText" is supposed to work?   How can I get the contents of the TextBox control to be "selected" when I click into the control?


Paul Squires

You could try setting the selection during the WM_LBUTTONUP message handler:


'--------------------------------------------------------------------------------
Function FORM1_TEXT1_WM_LBUTTONUP ( _
                                    ControlIndex  As Long,  _  ' index in Control Array
                                    hWndForm      As Dword, _  ' handle of Form
                                    hWndControl   As Dword, _  ' handle of Control
                                    MouseFlags    As Long,  _  ' virtual keys that are pressed
                                    xPos          As Long,  _  ' x-coordinate of cursor
                                    yPos          As Long   _  ' y-coordinate of cursor
                                    ) As Long

   FF_TextBox_SetSel hWndControl, 0, -1

End Function

Paul Squires
PlanetSquires Software

Martin Francom

#2
Paul,
   Thanks for the suggestion. I will give it a try.

Out of curiousity,  Is this the normal behavior for when a textbox control property is set to SelText to True.  I use several other windows programs where mouse clicking into a TextBox will select the text contained therein.  If it is possible I would like to see that be the behavior when a FF TextBox SelText property is set to True.  Is that possible? 

Rolf Brandt

That is the normal behaviour. The textbox will select the text when it gets the focus, so that its contents are overwritten when you start typing. A mouseclick will deselect the text. The idea is that you can can use the mouse to select the point in the text to make changes, or select part of the text.

If you want to have all text selected when you click the textbox you would have to program that manually.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Klaas Holland

You could doubleclick on the Textbox to select, perhaps you forgot.