5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:郑州
性别:先生
最后登录:2011-04-27
http://wwle.5d.cn/
我有一对翅膀,不是用来飞翔,而是用来煮汤。
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2008/02/14 | Tprinter of delphi
类别(语言类学习笔记)
|
评论
(0)
|
阅读(150)
|
发表于 20:39
Like TCanvas, the TPrinter class does not belong to BaseCLX because there are two separate versions, one for VCL applications (in the Printers unit) and one for CLX applications (in the QPrinters unit). The VCL TPrinter object encapsulates details of Windows printers. The CLX TPrinter object is a paint device that paints on a printer. It generates postscript and sends that to lpr, lp, or another print command. Both versions of TPrinter, however, are extremely similar.
To get a list of installed and available printers, use the Printers property. Both printer objects use a TCanvas (which is identical to the form's TCanvas) which means that anything that can be drawn on a form can be printed as well. To print an image, call the BeginDoc method followed by whatever canvas graphics you want to print (including text through the TextOut method) and send the job to the printer by calling the EndDoc method.
This example uses a button and a memo on a form. When the user clicks the button, the content of the memo is printed with a 200-pixel border around the page.
To run this example successfully, add Printers to your uses clause.
procedure TForm1.Button1Click(Sender: TObject);
var
r: TRect;
i: Integer;
begin
with Printer do
begin
r := Rect(200,200,(Pagewidth - 200),(PageHeight - 200));
BeginDoc;
Canvas.Brush.Style := bsClear;
for i := 0 to Memo1.Lines.Count do
Canvas.TextOut(200,200 + (i *
Canvas.TextHeight(Memo1.Lines.Strings[i])),
Memo1.Lines.Strings[i]);
Canvas.Brush.Color := clBlack;
Canvas.FrameRect(r);
EndDoc;
end;
end;
0
评论
Comments
日志分类
首页
[289]
教程习题
[21]
数据库学习笔记
[60]
语言类学习笔记
[75]
网页类学习笔记
[93]
其他相关笔记
[40]