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