Page 1 of 1

Position cursor within textbox

Posted: Wed Aug 07, 2019 1:20 pm
by Dermot
I wish to be able to display text in a textbox, and then position the cursor at the end of the that text, so that any further text entered by the user would then be added at the end.

Re: Position cursor within textbox

Posted: Thu Aug 08, 2019 8:08 am
by Dermot
I should have added that I have no problem with the display aspect, as I have been using LBB for years, and have developed a number of commercial programs. It is merely the cursor placement I am interested in, analagous to the texteditor command - print #handle, "!select column row" ;
I am not aware of such a command for a textbox

Re: Position cursor within textbox

Posted: Thu Aug 08, 2019 11:21 am
by guest
Dermot wrote:
Wed Aug 07, 2019 1:20 pm
I wish to be able to display text in a textbox, and then position the cursor at the end of the that text, so that any further text entered by the user would then be added at the end.
I'm sure it's quite straightforward using an API call (EM_SETSEL is the message you need), and somewhere I've got the code to do it. Unfortunately I'm bogged down with other things at the moment and cannot instantly find it.

Re: Position cursor within textbox

Posted: Sat Aug 10, 2019 2:08 pm
by sarmednafi
Richard,

Thank you, Here is the code,

Code: Select all


'Place text in textbox and locate
'caret at end of text.

nomainwin
textbox #1.t, 10,10,100,124
Open "Type" for window as #1
#1 "trapclose [quit]"
#1.t "!setfocus"
#1.t "Hello World"

startpos=len("Hello World")
endpos=startpos

hText=hwnd(#1.t)
calldll #user32, "SendMessageA",_
hText as ulong,_EM_SETSEL as long,_
startpos as long, endpos as long,_
re as long

wait

[quit] close #1:end

Regards

Re: Position cursor within textbox

Posted: Mon Aug 12, 2019 11:04 am
by Dermot
To Sarmednafi

Thanks very much
That works great

Regards

Dermot