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 control the print margins when printing a TRichEdit 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
07-Oct-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
57
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How do I set the left margin when printing the contents of a TRichEdit?

Answer:

You can set TRichEdit.PageRect for the margins. Get the printer information with 
GetDeviceCaps.

1   procedure TForm1.Button1Click(Sender: TObject);
2   var
3     PixelsX, PixelsY: integer;
4     LeftSpace, TopSpace: integer;
5     R: TRect;
6   begin
7     if PrintDialog1.Execute then
8     begin
9       {get pixels per inch}
10      PixelsX := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
11      PixelsY := GetDeviceCaps(Printer.Handle, LOGPIXELSY);
12      {get non-printable margins}
13      LeftSpace := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX);
14      TopSpace := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY);
15      {1' margin all around}
16      R.Left := Round(PixelsX * 1) - LeftSpace;
17      R.Right := Round(PixelsX * 7.5) - LeftSpace;
18      R.Top := Round(PixelsY * 1) - TopSpace;
19      R.Bottom := Round(PixelsY * 10) - TopSpace;
20      RichEdit1.PageRect := R;
21      RichEdit1.Print('Test');
22    end;
23  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