Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to draw a line in a RichEdit (just like in the Delphi Editor) Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
18-Oct-02
Category
Reporting /Printing
Language
Delphi 5.x
Views
130
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Maarten de Haan

How to draw a line in a RichEdit (just like in the Delphi editor)

Answer:

procedure DrawLine;

1   var
2     aCanvas: Tcanvas;
3     X1, X2, Y1: Integer;
4     byLineLength: BYTE;
5   
6   begin
7     byLineLength := 80; // Draw the line after 80 chars on the RichEdit
8     aCanvas := TCanvas.Create;
9     Y1 := RichEdit1.Height;
10    try
11      aCanvas.Handle := GetDC(RichEdit1.Handle);
12      aCanvas.Font := RichEdit1.Font;
13      X1 := aCanvas.TextWidth('W');
14      X2 := aCanvas.TextWidth('i');
15      aCanvas.Pen.color := clSilver; // Color of line
16      if X1 = X2 then // Check for fixed or variable font
17      begin
18        aCanvas.MoveTo(byLineLength * X1, 0);
19        aCanvas.LineTo(byLineLength * X1, Y1);
20      end;
21    finally
22      ReleaseDC(RichEdit1.Handle, aCanvas.Handle);
23      aCanvas.Free;
24    end;
25  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC