?
Solved

Print form

Posted on 1998-07-16
9
Medium Priority
?
255 Views
Last Modified: 2010-04-04
Hi

   I have to print a form and center it on the page. When i print the form (with form1.print), its always print it in the left top corner of the paper and i didnt want that. How can i center it ?
Id like to have some example.

Thanks
0
Comment
Question by:sierra20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 1

Expert Comment

by:pjdb
ID: 1357996
Var
  DestRect:TRect;
Begin
 Printer.BeginDoc;
 DestRect.Left:=Printer.Canvas.ClipRect.Left + (Printer.Canvas.ClipRect.Right - Form1.Width) div 2;
 DestRect.Right:=DestRect.Left + Form1.Width;
 DestRect.Top:=Printer.Canvas.ClipRect.Top + (Printer.Canvas.ClipRect.Bottom - Form1.Height) div 2;
 DestRect.Bottom:=DestRect.Top + Form1.Height;
 Printer.Canvas.CopyRect( DestRect, Form1.Canvas, Form1.ClientRect);
 Printer.EndDoc;
end;
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357997
Here is a code that draws the form image on the Printer.Canvas in the center by calculating coordinates:

Printer.BeginDoc;
Printer.Canvas.Draw(Printer.PageWidth/2 - Form1.GetFormImage.Width/2, Printer.PageHeight/2 - Form1.GetFormImage.Height/2, Form1.GetFormImage);
Printer.EndDoc

Cheers, Matvey
0
 
LVL 1

Expert Comment

by:pjdb
ID: 1357998
Use div instead of / for the division, the parameters need to be integer
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:Matvey
ID: 1357999
Of course, thanks.
0
 

Author Comment

by:sierra20
ID: 1358000
Ok, now im able to center the form but when i print it, it didnt print on all the paper, it just print the form really small. How can i print on all the paper??
0
 

Author Comment

by:sierra20
ID: 1358001
Ok, now im able to center the form but when i print it, it didnt print on all the paper, it just print the form really small. How can i print on all the paper??
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1358002
It's even easier - set form.PrintScale := poPrintToFit, and call form.print, or center it and print.
If you want your form to cover all the page, than you have to stretch it. Use Printer.Canvas.StretchDraw for this.
0
 

Author Comment

by:sierra20
ID: 1358003
Nice, its work now.
Just answers and thanks

0
 
LVL 3

Accepted Solution

by:
Matvey earned 150 total points
ID: 1358004
OK, glad it works.
As I said - use PrintScale or StretchDraw.
Good luck, Matvey
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

777 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