说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

报表制作技巧(三)-Delphi资料

HTML文档下载 WORD文档下载 PDF文档下载
报表制作技巧(三)-Delphi资料

任意打印

有时我们要打印任意排列的表或往已经印好的登记表上对号入座写上数据时,可以新建一个窗体(假设为Form1),再把Form1的BorderStyle设为bsNone、AutoScroll设为True,接下来再创建一个新窗体(假设为Form2),再建个按钮Button1,编写代码:

procedure TForm2.Button1Click(Sender: TObject);

begin

Form1.Width :=900;

Form1.Height :=800;

Form1.Print;

end;

接下来你在Form1上对应的位置写上数据,运行后按Button1就会一五一十的打印下来了。

打印机的分辨率问题?

Printer Resolution ?

问:

I want to know

wich way I have to program

so every print is equal. No

matter what resolution

of the printer (300 or 600 dpi).

Since now I program: TextOut(DC

150

150...) on a 300 dpi printer. But on

600 dpi

everything

looks a bit strange

(small).

What Objects can I use to print corectly??

答:

I get the printer resolution (and unprintable are if desired) and

then specify coordinates using decimal inches * resulution e.g.

x = trunc(1.5 * ResX) at 300 dpi will begin at 360 * 1.5 or 540 pixels.

Get Resolution and unprintable

ResX := GetDeviceCaps(ACanvas.Handle

LOGPIXELSX);

ResY := GetDeviceCaps(ACanvas.Handle

LOGPIXELSY);

pOffsetX := GetDeviceCaps(ACanvas.Handle

PHYSICALOFFSETX);

pOffsetY := GetDeviceCaps(ACanvas.Handle

PHYSICALOFFSETY);

print something

Printer.Canvas.TextOut(trunc(1.5 * ResX)-pOffsetX

trunc(2.5 * ResY)-pOffsetY

'Hello');

This is nice when printing data on an existing paper form as you can

just measure it up in decimal inches.

备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘