Article View: cn.bbs.comp.program
Article #2059Re: ���DELPHI�Ĵ�ӡ
From: ����
Date: Tue, 20 Jan 1998 00:00
Date: Tue, 20 Jan 1998 00:00
227 lines
9640 bytes
9640 bytes
�� �� ary (ary) �Ĵ������ᵽ: ��
: ���ʹ��DELPHI�е�TPRINTER����д�ӡ������
: лл������
:
����������Ϊת�أ���
��DELPHI �� �� �� ͼ �� �� �� ӡ
�� �� ÿ һ ��WINDOWS Ӧ �� �� �� �� �� �� �� ˵�� �� ӡ �� �� �� ʵ �� �� �� ��
Ϊ �� �� �ģ� �� Ϊ Ҫ �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �ӣ� �� ��
��DELPHI �� ʵ �� �� �� �� ͼ �� �� �� ӡ �� �� ȴ �� �� �� �� �� �ġ�
1�� �� �� �� �� ӡ �� �ܡ�DELPHI �� �� �� �� �� ӡ �� �� �� �� ͬ ��DOS �� ʵ ��
�� �� �� �� ӡ �� �� һ �� �� �ף� �� Ҫ �� �� һ �� ֻ �� ȡ �� �� ӡ �� �� �� �� ��
ӡ �� Ȼ �� �� �� �� �� �� ÿ һ �� �� �ݡ� ��DELPHI �� �� �� �� һ ��PRINTERS ��
�� �� Ԫ�� �� ˵ �� �� һ ��TPRINTER �� �� �� װ ��WINDOWS �� ӡ �� �� �� �� ��
�� ӡ �� ֮ �� �� �� �ڣ� �� �� �� �� �� �� �� �� �� �� ���� �� �� �� ��CANVAS �� һ
�� �� �� �� �� �� �� �ԣ� �� �� �� �� �� ǰ �� ӡ �� �� �� �� �棬 �� �� ͼ �� �� ʽ ��
�� �� �ģ� �� �� �� �� ӡ �� �� �� �� �� �� �� �� �� �� ӡ �� �� �� �� �� ��TPRINTER
�� �� ��CANVAS �ϣ� �� ȫ �� �� �� �� �� �� �� �� �� �� �� ӡ �� ��TPRINTER��
��CANVAS �� �� �� ֵ �� �� �� ӡ �� �� ȥ��
�� �� �� �� �� ˵ �� �� �� ͨ ��DELPHI ʵ �� �� �� �� �� �� �� ӡ�� ��DELPHI ��
�� �� ��PRINTDIALOG��PRINTERSETUPDIALOG �� �� �� �� �� �� �� �� �� �� �� ӡ
�� �� �� �� �� Ӱ �� �� ӡ �� �� �� ѡ �� �� �� �� �� Ҫ �� һ �� �� Ҫ �� ʵ �� �� ӡ
�� �� �� �� �� �� �� �� �� �� ǰ ��PRINTERS �� �� ��INTERFACE ��
��IMPLEMENTATION ��UESE �� �� �� �У� �� ΪPRINTER �� Ԫ �� ��ASSIGNPRN
�� �� �� �� �� �� ӡ �� �� �� �̡�
�� �� ��FORM �� �� �� ��MEMO��PRINTDIALOG��PRINTERSETUPDIALOG ��
�� ��BUTTON �� ���� �� �� BUTTON ��CAPTION �� �� Ϊ�� �� ӡ �� �á� �͡� ��
ӡ���� Ȼ �� �� дBUTTON �� �� �� �� �� �� �� �� �� �� �� �棩�� �� �� �� �� �� ��
�� �� ֻ Ҫ �� ���� �� ӡ�� �� ť ʱ �� �� �� �� �� ӡ �� �� �� �� �� ��0S2.TXT�� ��
ӡ �� �� �� �� �� �� �£�
implementation
uses printers;
{$R *.DFM}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
printersetupdialog1.execute; //ѡ������Ĵ�ӡ���Լ������ӡ����ѡ��
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
lines:integer;
prntext:system.text;
//��PRNTEXT����Ϊһ����SYSTEM����Ԫ���ж�����ı��ļ�
begin
if printdialog1.execute then
assignprn(prntext); //��PRNTEST������ӡ��
rewrite(prntext); //����REWRITE����Ϊ������ѷ�����ļ�
printer.canvas.font:=memo1.font;
//�ѵ�ǰMEMO1������ָ�����ӡ�����CANVAS����������
for lines:=0 to memo1.lines.count-1 do
writeln(prntext,memo1.lines[lines]);
//��MEMO������д����ӡ�����
system.close(prntext); //�رմ�ӡ�ļ�
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.lines.loadfromfile('c:\dos\os2.txt');
//��FORM����ʱ����C:\DOS\OS2.TXT�ļ�
end;
end.
2�� ͼ �� �� �� ӡ �� ��, �� �� �� ͼ �� �� ӡ �� �� Ҳ �� �� ӡ �� �� һ �� �� ��
�ף� ֻ �� �� �� �� ӡ �� �� ��TPRINTER�� �� ʼ �� ӡ�� �� ͼ �� �� �� �� �� �� ��
�� ӡ �� �� ȥ�� �� �� �� �� �� ӡ �� �� �� �� ӡ �� ����
�� �� ˵ ���� �� �� �� �� �� �� ��MEMO �� �� �� ��IMAGE �� ���� �� �� �� һ Щ
�� �� �� �� �ģ� ͼ �� �� ӡ �� �� �� �� �£�
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if printdialog1.execute then begin
printer.begindoc;
printer.canvas.draw(0,0,image1.picture.graphic);
printer.enddoc;
end;
end;
�� �� �� �� �� �£� ʹ �� �� �� �� ӡ �� �� �� �� �ʣ� ͼ �� �� ҳ �� �� �� �� �� ��
ʼ �� ӡ �� ���� �� �� �� ͼ �� �� С�� �� �� �� �� �� �� �� �� �� �� �� Ҫ �� �� ��
�� ӡ �� �� ��CANVAS ��STRETHDRAW �� �� ���� �� �� �� �� �� �� ͼ �� �� �� ��
�� �� �� �? �� ����CANVAS�� ��STRETCHDRAW �� �� �� �� ��
procedure StretchDraw(const Rect: TRect; Graphic: TGraphic);
���е�RECT������ͼ���������Ĵ�С��TRECT����������Ϊ��
TRect = record
case Integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end;
�� �� �� �� ֻ Ҫ �� ��RECT �� �� С �� �� �� �� ӡ ҳ �� �� �� λ �ã� �� �� �� ��
�� �� �� �� �� Ч �� �� �� �� �� �� �� �� �� �� �� �� ͼ �Σ� �� �� �� �� �� �� �� ��
�� �� �� �� �� �� �� λ �� �� ӡ �� �� ����CANVAS�� �� �� �� �� �� �� ���� �� ��
�� �£�
procedure TForm1.Button1Click(Sender: TObject);
VAR
strect:Trect; //�����ӡ������ο�Ĵ�С
temhi,temwd:integer;
begin
if printdialog1.execute then
begin
temhi:=image1.picture.height;
temwd:=image1.picture.width;
while (temhi printer.pageheight div 2)and
//��ͼ�ηŴ�ӡҳ���1/2��С
(temwd printer.pagewidth div 2) do
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strect do //����ͼ����ҳ���ϵ�����λ�����
begin
left:=(printer.pagewidth -temwd) div 2;
top:=(printer.pageheight-temhi) div 2;
right:=left+temwd;
bottom:=top+temhi;
end;
with printer do
begin
begindoc;
canvas.stretchdraw(strect,image1.picture.graphic);
//���Ŵ��ͼ�����ӡ�����
enddoc;
end;
end;
end;
�� �� �� �� ��DELPHI2.0 �� �� �� ͨ �� ͨ �� �� Щ С С �� �� �ӣ� �� �� �� ��
�� �� ��DELPHI �� �� ӡ ͼ �� �� �� �� �� һ �� �� �� �⣬ ͬ �� ͨ �� �� ӡ �� �� ��
����CANVAS�� �� �� Ҳ �� �� ʵ �� �� �� �� �� �� �� �� ӡ�� �� �� �� �� һ һ
���� �� �� �� �� �� �� Ȥ �� �� һ �ԡ�
--
[1;36m ��Դ: ����������BBSվ��bbs.nease.net�E[FROM: www-post@bbs.nease.n]
Technical Details
Message-ID:
<3Maf3l$SP4@bbs.nease.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB X-Google-Thread: fc86e,39a2fb0826616156,start X-Google-Attributes: gidfc86e,public From: longly.bbs@bbs.nease.net (����) Subject: Re: ���DELPHI�Ĵ�ӡ Date: 1998/01/20 Message-ID: <3Maf3l$SP4@bbs.nease.net> X-Deja-AN: 317580626 X-Filename: Program/M.885273023.A Organization: gzdcb Newsgroups: cn.bbs.comp.program,