Solved

Top visible line in a RichEdit

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

929 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

10 Experts available now in Live!

Get 1:1 Help Now