TRichEdit, D5, How To Locate Exact Carot Pos on Screen.

All i want to do is locate the carot pos ( for displaying a hint by the text cursor ( a bit like delphi hints ) ), but no matter what i do, im having a problem getting the pos if the RichEdit has lots of text, and the page is scrolled down, the carot pos allways seems to be the position from the top of the richedit.
i cannot find any reference to the actual pos, or even the page showing rect / point variabls, so there doesnt even seem to be a way of deriving the value.

so can anyone tell be how to get the exact carot pos in a TRichEdit, taking into consideration scrolling / Screen position.
but either :
get pos,
Get showing screen pos of the richedit so i can work it out,
get pos from screen directly,
or some other means with code example.

Thank you in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

a sample

unit Unit1;


  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ComCtrls;

  TForm1 = class(TForm)
    Label1: TLabel;
    RichEdit1: TRichEdit;
    Label2: TLabel;
    Timer1: TTimer;
    procedure RichEdit1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Timer1Timer(Sender: TObject);
    { Private declarations }
    { Public declarations }

  Form1: TForm1;


{$R *.dfm}

uses richedit; //richedit used

procedure TForm1.RichEdit1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
  label1.Caption := inttostr(x)+':'+inttostr(y);

//caret coords within the richedit-clientarea
procedure TForm1.Timer1Timer(Sender: TObject);
var p : tpoint;
  label2.Caption := inttostr(p.x)+':'+inttostr(p.y); //maybe some minimal offset is needed


meikl ;-)
if you need it converted to screen-coords

//caret cooods within the richedit
procedure TForm1.Timer1Timer(Sender: TObject);
var p : tpoint;
  label2.Caption := inttostr(p.x)+':'+inttostr(p.y);
  //converted to screencoords
  p := Richedit1.ClientToScreen(p);
  label3.Caption := inttostr(p.x)+':'+inttostr(p.y);

meikl ;-)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KristianAuthor Commented:
yeah, thats perfect.
like you said a little offset but.

i used,

function GetCarotPos(Memo : TRichedit):TPoint;
  result.x := result.x + Memo.ClientOrigin.x;
  result.y := result.y + Memo.ClientOrigin.y + Memo.DefAttributes.Height + 5;

but i think ClientToScreen does the same thing doesnt it?
Anyway thank you very much.
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

>but i think ClientToScreen does the same thing doesnt it?
yep, should be the same result

glad to helped you

meikl ;-)
KristianAuthor Commented:
did you just send a 3rd comment,
i got a 3rd notification, BUT i cannot view it, it only comes up with 2 comments from you, is this a EE notify bug, or EE View bug?
KristianAuthor Commented:
( after sending message, i got it now, dont worry, very wierd though ) cheers again.
>is this a EE notify bug, or EE View bug?
no, its just the cache of your browser,
just use the link

Reload This Question

if this happens

meikl ;-)

KristianAuthor Commented:
( same again )
so this is so i can view the message,

and i have shut explorer and pressed the link again,
have pressed refresh,
and nothing. so hopefully this message will show again.
( how can i report this to EE ? )
KristianAuthor Commented:
well i did do ( re my 1st message ) what you said,
and that didnt work,
is it maybe my cache options then ?

you don't have to shutdown your browser,
nor to press the refresh button

you have on this page
(upper-left in expert mode, upper-right in normal mode)
a framed box titled "your status" followed by your name.

in this box is a link
"Reload This Question"

you have only to click on this link,
to get the actual content, thats all

meikl ;-)
KristianAuthor Commented:
KristianAuthor Commented:
Ok found it,
i will do this in future,
:-)) just as test

btw. this happens to me too often,
that i click the question-link
in the notification-mail and get
the old content from the browser-cache

it is really not a bug of ex-ex, its just
a normal bahaviour of the browser-technic

meikl ;-)
KristianAuthor Commented:
now it worked fine that time....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.