Solved

Trichedit : Offset

Posted on 2000-03-21
6
394 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

825 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