Seleccionar todo el texto en un TextBox

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Seleccionar todo el texto en un TextBox

Post by mol »

Thanks Jimmy for your work, but everything works OK with the keyboard, and everything goes wrong with the mouse.
I've prepared little function, which call should be placed in OnGetFocus statement.
It works perfectly for me:

Code: Select all

#define WM_SETTEXT 12
function ClearTextBoxIfEmpty
	
	if empty(this.Value)
		SendMessage( GetControlHandle(This.Name, ThisWindow.Name) , WM_SETTEXT , 0, "" ) 
	endif
return
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Seleccionar todo el texto en un TextBox

Post by AUGE_OHR »

hi Mol,

now i "see" the Differenz.

my Code does "hilight" TEXTBOX when click into it
but it does not "clear" TEXTBOX when begin to type into. it will be "add" at Caret Position

so try to change

Code: Select all

   SetProperty( ParentForm, ControlName, "CaretPos", nEndIndex )
into

Code: Select all

   SetProperty( ParentForm, ControlName, "CaretPos", nStartIndex )
to get right Start Position

btw. how to "switch" between "INSERT" and "OVERRIDE" in TEXTBOX / EDITBOX :?:
have fun
Jimmy
Post Reply