Cursor Position in TextField

BlitzPlus Forums/BlitzPlus Programming/Cursor Position in TextField

pantsonhead.com(Posted 2004) [#1]
Is there a way to control the cursor position in a textfield?

Problem Example:
I have a textfield that contains "apple" with the cursor at the end (after the "e"). I then change the text using SetGadgetText(textfield,"Pineapple")
The cursor is now after the "a" and I can't seem do do anything about that.

Unless I'm missing something simple here I think it's time to learn another API call...


pantsonhead.com(Posted 2004) [#2]
OK, I've found it...

Here's how to set cursor/selection in a textfield (probably a textarea too).
EM_SETSEL = $B1
SendMessage(QueryObject(textField,1), EM_SETSEL, startPos, endPos)

Remember:
startPos/endPos are 0 based,
use the same value for startPos/endPos to position the cursor,
use different startPos/endPos values to select some of the text

EDIT:
...and now i find this:
http://www.blitzbasic.com/Community/posts.php?topic=25196