Page 1 of 1

TPrinter-How can make same.

PostPosted: May 25th, 2004, 8:31 am
by Kyoung-hoon Kim
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?

PostPosted: June 28th, 2004, 7:22 am
by Kambiz
It's because of the difference between screen's resolution and printer's resolution. By scaling you should make two resolutions identical.