Link to home
Start Free TrialLog in
Avatar of titz
titz

asked on

Trichedit : Offset

hi,

under D3/Win98 i have a Trichedit with scrollbars
and a large text inside.
when the vertical scrollbar is used, i want to know
how many pixels offset has the first visible line
to the first line of the text.
or in other words: how many pixels are scrolled ?

thanks
titz
Avatar of kotik
kotik

Hi!
It's only a suggestion, try this:

var
  Position: integer;
begin
  SendMessage(RichEdit.Handle, EM_POSFROMCHAR, Position, 0
);
end;

Regarding to the Win32 Help:
A returned coordinate can be negative if the character has been scrolled outside the edit control's client area.

So you can get abs(Position) to get the real offset.

Regards,
Kot.



ASKER CERTIFIED SOLUTION
Avatar of kotik
kotik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of titz

ASKER

hi kotik,

that was the exact answer ! it works well.

but i have an additional question: i thought i could get the action of the scrollbars in an onpaint-event.
but now i found : there is no onpaint-event in Trichedit. Do you have an idea what kind ogf event i can use for to know that the scrollbars are active ?

thanks
titz
 
To be able to handle scrollbar events you have to create your own handler, like this (I have done it for a TMemo, but I think it will work with TRichEdit too):
interface
....
{ Add to your RichEdit component }
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
....

implementation

procedure TFileMemo.WMVScroll(var Message: TWMVScroll);
begin
  { Do what you need here }
  Inherited; // call inherited, if you need it
end;

You can get more info in Win32 Help. Look for WM_SCROLL message.

Tell me if you have problems with implementing.

Regards,
Kot.





Avatar of titz

ASKER

hi kotik,

thanks: it works. i did the same before (with wm_vscroll-message), but i
forgot the "inherited" .

Many thanks and a nice weekend
titz
Glad to help you.

Regards,
Kot.

P.S. Nice nickname :)