Solved

Trichedit : Offset

Posted on 2000-03-21
6
389 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:titz
  • 4
  • 2
6 Comments
 
LVL 2

Expert Comment

by:kotik
ID: 2641286
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.



0
 
LVL 2

Accepted Solution

by:
kotik earned 50 total points
ID: 2641312
This is the correct version:


{ Y coordinate is what you need }
procedure TForm1.Button2Click(Sender: TObject);
var
  Position: TPoint;
begin
  SendMessage(RichEdit1.Handle, EM_POSFROMCHAR, Integer(@Position), 0);
  Label1.Caption := Format('CordX: %d, CordY: %d', [Position.X, Position.Y]);
end;

Regards,
Kot.
 
0
 
LVL 1

Author Comment

by:titz
ID: 2650279
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
 
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 2

Expert Comment

by:kotik
ID: 2653834
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.





0
 
LVL 1

Author Comment

by:titz
ID: 2654448
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
0
 
LVL 2

Expert Comment

by:kotik
ID: 2654543
Glad to help you.

Regards,
Kot.

P.S. Nice nickname :)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now