Solved

Pagerect and Richedit

Posted on 1997-10-11
5
1,030 Views
Last Modified: 2013-11-22
A while ago I found this code for printing with Richedit, but if I use it as below only have a page gets printed, and then a new one starts, and I only got to specify left and topmargin. Can you please show me how the correct settings should be for a standard A4 page with a leftmargin of 10mm, Topmargin 20mm, Bottommargin also 20mm and rightmargin of 15mm, please write it so That it works Immediate if I paste it in my code Thanks.


RichEdit1.PageRect := Rect(100, 100, Printer.PageHeight, Printer.PageWidth);
RichEdit1.Print(...);
0
Comment
Question by:hellfire052497
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
mirek071497 earned 100 total points
ID: 1347280
var
 Loff, TOff, ROff, BOff   : integer;
 XRes, YRes, XOffs, YOffs : integer;
begin
  { set your needed values in milimeters }
  LOff := 10;
  TOff := 20;
  ROff := 15;
  BOff := 20;
  { Get printer data }
  XOffs := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX ); { minimum Left offset }
  YOffs := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY ); { minimum Top offset }
  XRes := GetDeviceCaps(Printer.Handle, LOGPIXELSX); { points per inch in X }
  YRes := GetDeviceCaps(Printer.Handle, LOGPIXELSY); { points per inch in Y }
  {Change Your values to printer Units }
  LOff := Round(LOff*XRes/25.4)-XOffs; { of course You can't set margins less than min offset !!! }
  TOff := Round(TOff*YRes/25.4)-YOffs; { of course You can't set margins less than min offset !!! }
  ROff := 2490-Round(ROff*XRes/25.4)-XOffs; { changing to width, not offset !!!}
  BOff := 3510-Round(BOff*YRes/25.4)-YOffs; { changing to height, not offset !!!}
  { print RichEdit }
  RichEdit1.PageRect := Rect( LOff, TOff, ROff, BOff );
  RichEdit1.Print( 'TEST A4 ' );
end;

0
 

Author Comment

by:hellfire052497
ID: 1347281
I just noticed that this code is skipping a lot of text about half a page between printed pages, and also that the text when reaching the right margin doesn't get printed and gets lost.
thus giving a lot of clipping. so it isn't correct just yet
please check what is wrong
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1347282
Ok. I will try to test this. Wait to tomorrow.
0
 

Author Comment

by:hellfire052497
ID: 1347283
for your information I use richedit in a fixed size of;
Height : 257
Width: 593

0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1347284
Sorry for the long time.
In My exampele all works fine. Can you send me your example ? Mayby I found what is going on.
mirek@izabell.itcomp.tpnet.pl
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

15 Experts available now in Live!

Get 1:1 Help Now