Solved

Trichedit : Offset

Posted on 2000-03-21
6
397 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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