DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TPrinter-How can make same.

 
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming
View previous topic :: View next topic  
Author Message
Kyoung-hoon Kim
Member


Joined: 25 May 2004
Posts: 1
Location: ? Started With Delphi 6.0 a Few Months ago.

PostPosted: 25/05/04 08:31    Post subject: TPrinter-How can make same. Reply with quote

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:

///////////////////////////////////////////////////////////////
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.
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 409
Location: Tehran, Iran

PostPosted: 28/06/04 07:22    Post subject: Reply with quote

It's because of the difference between screen's resolution and printer's resolution. By scaling you should make two resolutions identical.
Back to top
View user's profile Send e-mail Visit poster's website
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group