Thursday, 22 August 2013

EM_EXGETSEL does not relate to text selection order. How do I do determine the cursor position in a piece of selected text?

EM_EXGETSEL does not relate to text selection order. How do I do determine
the cursor position in a piece of selected text?

When I do:
SendMessage(editControlHWND, EM_EXGETSEL, 0, (LPARAM)&charRange);
I get the selected range of text. However, I want to know where the cursor
is in this selection, ie at the end, OR at the beginning.
ie, has the user selected the text 'backwards', as in something like
dragging from right to left.
EM_EXGETSEL will always have the smaller number in cpMin, so clearly does
not relate to the selection order.
I obviously can't get the cursor position with EM_EXGETSEL for comparison
in this situation because a chunk of stuff is already selected.
Is there any way to get the cursor's current individual position (so that
I can compare it to cpMin/cpMax)? Or alternatively, is there any way of
determining where the cursor is in a block of selected text?

No comments:

Post a Comment