Edit Control: caret position before of after selection?
Posted: 09 Oct 2014, 02:44
Hi all,
I can get the current caret position with "ControlGet, outputVar, CurrentCol, ...". However if text is selected then it will always return the position of where the selection starts.
Now, in real life, however, the caret could be at the start or at the end of the selection. The difference in behaviour becomes clear if I continue to select more text on top of what is already selected. In this case my current selection could get (partly) deselected or not, depending if the caret was at the start or end of the current selection.
I want to code this behaviour it on my own and I found some Edit Control libraries in the forums, but when I select text with "SendMessage, 0xB1, start, end, %Control%, %WinTitle% ; EM_SETSEL" then any current selection is completely replaced instead of taken into account.
So, is there a way to find out if the caret is positioned at the start or end of a current selection?
Thx to everybody helping.
EDIT:
Found a solution: http://arstechnica.com/civis/viewtopic. ... 6#p3347986
I quote the author, "ToLazyToThink": "Calling EM_SETSEL with a -1 for the start position should undo the selection, leaving the caret where it was.
If you want a non-destructive method, I don't know of one. When I needed one I used the trick above and then used a bunch of hackery to restore the previous selection."
I can get the current caret position with "ControlGet, outputVar, CurrentCol, ...". However if text is selected then it will always return the position of where the selection starts.
Now, in real life, however, the caret could be at the start or at the end of the selection. The difference in behaviour becomes clear if I continue to select more text on top of what is already selected. In this case my current selection could get (partly) deselected or not, depending if the caret was at the start or end of the current selection.
I want to code this behaviour it on my own and I found some Edit Control libraries in the forums, but when I select text with "SendMessage, 0xB1, start, end, %Control%, %WinTitle% ; EM_SETSEL" then any current selection is completely replaced instead of taken into account.
So, is there a way to find out if the caret is positioned at the start or end of a current selection?
Thx to everybody helping.
EDIT:
Found a solution: http://arstechnica.com/civis/viewtopic. ... 6#p3347986
I quote the author, "ToLazyToThink": "Calling EM_SETSEL with a -1 for the start position should undo the selection, leaving the caret where it was.
If you want a non-destructive method, I don't know of one. When I needed one I used the trick above and then used a bunch of hackery to restore the previous selection."