Here you go ...
; Highlight Text in edit control
; userlibs
; ************************
; .lib "user32.dll"
; SendMessage%(hwnd,msg,wParam,mParam):"SendMessageA"
; ************************
win = CreateWindow("Highlight TextField text",176,193,244,123,Desktop(),16+1)
tf = CreateTextField(20,20,200,20,win,0)
bt = CreateButton("Highlight text",70,60,100,22,win)
SetGadgetText tf,"Hello World"
Repeat
ev=WaitEvent()
Select ev
Case $803 ; close [X]
Exit
Case $401 ;gadgethit
If EventSource()=bt HighlightTextFieldText tf
End Select
Forever
End
; highlight characters in an 'edit control'
Function HighlightTextFieldText(gad,offs=0,numchars=-1)
Local EM_SETSEL=$b1
ActivateGadget gad
SendMessage QueryObject(gad,1),EM_SETSEL,offs,numchars+offs
End Function
NOTE: Using the HighlightTextFieldText() without the offset and numchars parameters will highlight all text in the field.
|