Solved

Top visible line in a RichEdit

Posted on 2001-07-29
3
207 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

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!

Question has a verified solution.

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

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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

687 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