TPrinter-How can make same.

Please discuss general Delphi programming topics here.

TPrinter-How can make same.

Postby Kyoung-hoon Kim » May 25th, 2004, 8:31 am

Hi. This is my First Question on DELPHIAREA.
I'm programming the printing app which have preview function.
But, don't use TPrintPreview from DELPHIAREA. It just for my study.

First, here's my code.
Code: Select all
///////////////////////////////////////////////////////////////
unit Main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls, printers, Winspool;

type
TForm1 = class(TForm)
   Image1: TImage;
   btnPreview: TButton;
   btnPrint: TButton;
   procedure btnPreviewClick(Sender: TObject);
   procedure btnPrintClick(Sender: TObject);
   procedure FormShow(Sender: TObject);
private
   { Private declarations }
public
   { Public declarations }
end;

var
Form1: TForm1;

implementation

uses Types;

{$R *.dfm}


procedure DrawLine(Canvas: TCanvas);
begin
with Canvas do
begin
   Brush.Color := clNavy;
   Brush.Style := bsDiagCross;
   Rectangle(100, -2200, 2000, -2500);

   Pen.Color := clRed;
   Brush.Color := clYellow;
   Ellipse(100, -1000, 8000, -1200);

end;
end;



//--- TO Preview ---

procedure TForm1.btnPreviewClick(Sender: TObject);
begin
  SetMapMode(Image1.Canvas.Handle, MM_LOMETRIC);
  DrawLine(Image1.Canvas);
end;


//--- TO Print ---

procedure TForm1.btnPrintClick(Sender: TObject);
begin
  Printer.BeginDoc;
  SetMapMode(Printer.Handle, MM_LOMETRIC);
  DrawLine(Printer.Canvas);
  Printer.EndDoc;
end;


procedure TForm1.FormShow(Sender: TObject);
begin
  btnPreviewClick(self);
end;

end.

//////////////////////////////////

But, I can't make them look same, the look from Monitor and the look from printed paper. Or, How can I get the size of the 'Image1' to make them look same?
? Started With Delphi 6.0 a Few Months ago.
Kyoung-hoon Kim
Member
Member
 
Posts: 1
Joined: May 25th, 2004, 1:33 am
Location: ? Started With Delphi 6.0 a Few Months ago.

Postby Kambiz » June 28th, 2004, 7:22 am

It's because of the difference between screen's resolution and printer's resolution. By scaling you should make two resolutions identical.
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron