Code archives/Miscellaneous/SetTextAreaSel
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
B+ v1.34 it works like TextArea commands. Userlibs : userlibs/user32.decls .lib "user32.dll" SendMessage%(hwnd, msg, wParam, mParam):"SendMessageA" Example win=CreateWindow("",0,0,300,330,0,1) txt=CreateTextArea(5,5,280,250,win) selectALL=CreateButton("select ALL",5,260,280,32,win) Repeat If EventID()=$401 And EventSource()=selectALL ;select all the text SetTextAreaSel(txt,0,TextAreaLen(txt,2),2) EndIf Until WaitEvent()=$803 functions : | |||||
Function SetTextAreaSel(txt,pos,len,units) Local EM_SETSEL=$B1 If units=1 [#C0FF00];selection by characters[#00FF00] sendmessage(QueryObject(txt,1), EM_SETSEL, pos,pos+len) Else [#C0FF00];selection by lines[#00FF00] Local posligne=TextAreaChar(txt,pos ) len=TextAreaChar(txt,pos+len)-posligne sendmessage(QueryObject(txt,1), EM_SETSEL, posligne,posligne+len) EndIf End Function |
Comments
None.
Code Archives Forum