Solved

Top visible line in a RichEdit

Posted on 2001-07-29
3
206 Views
Last Modified: 2013-11-22
Hi!
Can anybody tell me how I can receive the number of the line that is displayed on the top of a RichEdit component. I would also be satisfied with getting the character position (like StartSel does) of this first line, because all the lines have identical length, and so it would only require a simple division.
Regards, Hamilton.
0
Comment
Question by:Hamilton
[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
3 Comments
 
LVL 21

Expert Comment

by:gemarti
ID: 6331332
If you are going to be clicking on the position at the top of the richedit control you can use this code to get the line number:

var
  Point : TPoint;
begin
  Point := RichEdit1.CaretPos;
  ShowMessage(IntToStr(Point.X)+ ' ' +IntToStr(Point.Y));
end;
0
 
LVL 5

Accepted Solution

by:
alanwhincup earned 100 total points
ID: 6331377
Try this:

procedure TForm1.Button1Click(Sender: TObject);
var
  VisibleLine : Integer;
begin
  VisibleLine := RichEdit1.Perform(EM_GETFIRSTVISIBLELINE, 0 , 0);
  ShowMessage(IntToStr(VisibleLine));
end;
0
 

Author Comment

by:Hamilton
ID: 6332384
Your code example is working very well! Thank you! :-)
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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