This wasn't intended but eventually becomes a followup on "Where is the caret?"
There are two directions to select some text in a rich edit: from left to right, or from right to left. The initial position of a selection is called an anchor point, and the ending position is called an active end. These are the names given in the EM_SETSEL documentation. The four other related messages and notification are: EM_GETSEL, EM_EXSETSEL, EM_EXSETSEL, and EN_SELCHANGE.
Since the caret marks the active position, to reshow or do something interesting with the caret, I need to know where the anchor and active positions are, given a selection range. As it turns out, all of above messages or notification (except EM_SETSEL) assume the start/min being anchor, and end/max being active.
Quite surprisingly, TOM can provide this information, through ITextDocument:GetSelection and ITextSelection:GetFlags (tomSelStartActive). I said surprising because TOM looks more like wrapper interfaces around Word and rich edit controls, but hey, what do I know?
Wednesday, September 15, 2010
Subscribe to:
Posts (Atom)