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 display text from a TRichEdit on the canvas of a TGraphicControl 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
12-Oct-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
96
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to display text from a TRichEdit on the canvas of a TGraphicControl

Answer:

If you just want to view the text you can make a component derived from 
TGraphicControl. The following code shows how to put text from a TRichEdit control 
on the canvas of the TGraphicControl.
1   
2   {rtf is a property of the TRICHLABEL of the type TRichEdit }
3   
4   procedure TRICHLABEL.Paint;
5   var
6     myFormatRange: TFormatRange;
7     myCharRange: TCharRange;
8     myRect: TRect;
9     OldMap: Integer;
10    LastChar: Integer;
11    rc: TRect;
12    hDC, hDCTarget: THandle;
13  begin
14    if not Assigned(rtf) then
15      exit;
16    FillChar(myFormatRange, sizeof(TFormatRange), 0);
17    myCharRange.cpMin := 0;
18    myCharRange.cpMax := -1;
19    canvas.brush.color := BackColor;
20    if FTransparent then
21      Canvas.brush.style := bsClear
22    else
23    begin
24      Canvas.brush.style := bsSolid;
25      Canvas.FillRect(ClientRect);
26    end;
27    with myFormatRange do
28    begin
29      hDC := canvas.handle;
30      hDCTarget := canvas.handle;
31      rc := Rect(0, ptOrigin.y * 15, Width * 15, ptOrigin.y * 15 + Height * 15);
32      chrg.cpMin := 0;
33      chrg.cpMax := -1;
34    end;
35    LastChar := SendMessage(rtf.handle, EM_FORMATRANGE, 1, LPARAM(@myFormatRange));
36    myRect := Rect(0, 0, width * 15, height * 15);
37    SendMessage(rtf.handle, EM_DISPLAYBAND, 0, LPARAM(@myRect));
38    LastChar := SendMessage(rtf.handle, EM_FORMATRANGE, 0, LPARAM(nil));
39  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