i want to select a single character from where the Caret position is.

if editbox is: "I Love P|rogramming"

the caret is after the 'P', and depend on where i press with mouse somewhere along the text i want to highlight the current char after the |
in the above example, we press with mouse on after the 'P' and the 'r' whould be highligted.
i tried find sulotions, but faild to :(
any idea?
Posted on 2003-10-30 12:09:59 by wizzra
First make sure your edit control has the ES_NOHIDESEL style.
invoke SendMessage,hEdit,EM_GETSEL,NULL,NULL

and eax,0ffffh
mov ecx,eax
inc ecx
invoke SendMessage,hEdit,EM_SETSEL,eax,ecx
Posted on 2003-10-31 02:45:40 by Morris
EM_GETSEL message to get the starting and ending character positions of the current selection in an edit control

My EditBox doesn't have any text selected, i want to select the next char from where the caret ( | sign) is.
i need to get the Position of the caret but dunno how.

using your code, the return value is always 0 in eax, no metter where you press in the editbox.

visual aid at the picture.
Posted on 2003-10-31 06:19:03 by wizzra
If there is no selection in the edit box, EM_GETSEL returns the position of the caret - sel_start and char_after_selection values are the same, where sel_start is EAX & 0ffffh and char_after_selection is EAX shr 16

Here's another solution:
invoke GetCaretPos,addr tpCaretPos

mov eax,tpCaretPos.y
shl eax,16
or eax,tpCaretPos.x
invoke SendMessage,hEdit,EM_CHARFROMPOS,0,eax
and eax,0ffffh
mov ecx,eax
inc ecx
invoke SendMessage,hEdit,EM_SETSEL,eax,ecx
where tpCaretPos is a POINT structure
Posted on 2003-10-31 06:40:51 by Morris
Hi Morris,

yes it works now thnx!!
it didn't worked cuz i used an invalid HWND of the editbox :stupid: :grin:
thnx again.
Posted on 2003-10-31 07:10:19 by wizzra