Is there a way to determine the current position of the cursor in a TextBox?
Local nStartPos As Long
Local nEndPos As Long
SendMessage hWndControl, %EM_GETSEL, VarPtr(nStartPos), VarPtr(nEndPos)
http://www.powerbasic.com/support/pbforums/showthread.php?p=330746#post330746
Paul,
I am not quite sure I understand.
Lets say I have a TextBox with these charactes in it:
[1234567890] (brackets [] just symbolize the textbox)
and lets say the cursor is on the 6 which happens to be in the sixth position the the textbox. Note that no text is highlighted. If a person was to press a key the character would insert right after the 6. So, when I use the SendMessage which of those variables is going to tell me the location of the cursor?
Can you correct this for me:
local CurLoc as long ' Cursor Location in TextBox
CurLoc = SendMessage hWndControl, %EM_GETSEL, VarPtr(nStartPos), VarPtr(nEndPos)
A fellow on the PB forum help me understand. I think I have it now. From his example program.
I see that when no text is highlight (selected) then the
nStartPos and nEndPos are the same value that value being
the current location of the cursor. And when some text
is highlighted then the values are different but the nStartPos
is always the location of the cursor where text insertion would
begin.
So if I am interested in the location of the cursor then the
value I need to use is the nStartPos