Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 May : RichEdit + EM_CHARFROMPOS
| Subject: | RichEdit + EM_CHARFROMPOS |
| Posted by: | "Alan Prose" (..@) |
| Date: | Tue, 31 May 2005 23:14:48 |
Hello group
I'm having a problem with the TRichEdit control - right clicking within the control doesn't move the caret, so I found some Google
Groups archived samples that demonstrated how to shift its position manually.
var
CursorPt: TPoint;
...
CursorPt := Point(X, Y);
CharIndex := LoWord(ARichEdit.Perform(EM_CHARFROMPOS, 0, Integer(@CursorPt)));
ARichEdit.SelStart := CharIndex;
...which works fine if the cursor position evaluates to a value less than 65535. If the value is more than 65535, EM_CHARFROMPOS
seems to deduct 65535 from the index it returns. I *would* just add High(Word) to whatever EM_CHARFROMPOS was giving me... but
that's obviously no good when the value REALLY IS something less than 65535 - I haven't figured out a way to make that distinction.
Any suggestions much appreciated!