ListView的打印预览问题?急急急!!!

lfd_boy 2002-11-22 05:10:07
请问各位高手:
怎么实现ListView的打印预览和打印???

一定给分!

如果有例子可以发到:lfd_boy@163.com


谢谢!!!

...全文
97 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdimp 2002-11-22
  • 打赏
  • 举报
回复
up
cgh1970 2002-11-22
  • 打赏
  • 举报
回复
up
vickeen 2002-11-22
  • 打赏
  • 举报
回复
用控件也很好呀!
http://www.tmssoftware.com 上应该有!
vickeen 2002-11-22
  • 打赏
  • 举报
回复
看完后应该很简单了吧,记住要勤学,不要什么都靠别人。
procedure TForm1.Button1Click(Sender: TObject);
var
f: textfile;
i,j : integer;
str : string;
begin
assignfile(f,'c:\test.txt');
rewrite(f);
str := '';
for i := 0 to listview1.Columns.Count - 1 do
str := str + listview1.Columns[i].Caption + ' ';
writeln(f,str);
str := '========================';
writeln(f,str);
for i := 0 to listview1.Items.Count - 1 do
begin
str := listview1.Items[i].Caption + ' ';
for j := 0 to listview1.Items[i].SubItems.Count - 1 do
str := str + listview1.Items[i].SubItems[j] + ' ';
writeln(f,str);
end;
closefile(f);
end;
vickeen 2002-11-22
  • 打赏
  • 举报
回复
Delphi文本和图形的打印方法


一、基本知识

1、在代码单元的Uses部分增加Printers,打印实际上是把要打印的内容画到tprinter的canvas画布上。

2、选择输出的打印机:printdialog1.execute

3、选择打印控制选项 printersetupdialog1.execute;


二、打印文本

//打印Memo1中的内容

procedure TForm1.BitBtn1Click(Sender: TObject);

var

lines:integer;

prntext:text; 定义打印文本变量

begin

if printdialog1.execute then

assignprn(prntext); //将prntext文件分配给打印机

rewrite(prntext); //打开prntext文件

printer.canvas.font:=memo1.font; //设置打印对象的canvas的字体

for lines:=0 to memo1.lines.count-1 do

writeln(prntext

memo1.lines[lines]); //把Memo1的内容写到打印机对象

system.close(prntext); //关闭打印文件

end;


三、打印图形

1、利用打印机的分辨率,图形将打印在页面的左上角,图形较小。

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;

2、利用打印机画布canvas的stretchdraw方法

可以对图形进行更为灵活的处理。

其中要用到一个代表图形输出区域的Rect参数

Trect的类型定义如下:

TRect = record

case Integer of

0: (Left

Top

Right

Bottom: Integer);

1: (TopLeft

BottomRight: TPoint);

end;  


例:通过调整Rect的范围、图形大小及其在打印页面上的位置,实现图形打印:

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;

记得给分:)

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧