网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Delphi
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.远程控制篇:服务端程序关机时的.
.语法高亮.
.在Delphi窗口中创建IE风格的菜单.
.Delphi中MIDAS如何控制前台权限(.
.Delphi图象截取编程示例(7).
.自定义的TShockwaveflash.
.字符串函数大全.
.通用查询组件设计.
.在delphi字符中包括单引号(').
.制作QQ消息炸弹.
.自绘XP风格菜单.
.代替showmodal其他两种方法.
.200开发技术年度综述之Windows开.
.运行期间生成代码的动态执行.
.在Firebird里如何防止空值扩散.
.SQL在Delphi数据库程序设计应用浅.
.[PB+Delphi]主应用程序用的是PB,.
.Delphi控件的拿来主义(三).
.在Delphi中如何控制其它应用程序.
.Delphi编程实现Ping操作.

用Ehlib二次开发报表打印程序,实现财务凭证的打印(三)

发表日期:2006-2-4


 

4、打印表头,我将表头的各个部分划成了几部分,如我的凭证打印的地方,我就划成了五部分,每部分按占百分比多少计算。如编制单位就占页面宽度的40%等

procedure TF_printpreview.printpageheader(pageheader: Tstrings);
var
  Headrect:Trect;
  count:integer;
begin
  pp_pz.Printer.Canvas.Font.Name:='宋体';
  pp_pz.Printer.Canvas.Font.Color:=clblack;
  pp_pz.Printer.Canvas.Font.Size:=9;
  pp_pz.Printer.Canvas.Font.Style:=[];
  gettextinfo;
  Amountprint:=Amountprint+round(0.8*textheight);//当前逻辑尺的位置
  for  count:=0 to pageheader.Count-1 do
  begin
    case count of
      0:
       HeadRect:=Rect(round(pp_pz.Printer.PageSet.LeftMargin),Amountprint,round(pp_pz.Printer.PageSet.LeftMargin+round(0.4*(pp_pz.Printer.PageWidth))),Amountprint+textheight);//编制单位比例
      1:
       HeadRect:=Rect(headrect.Right,Amountprint,headrect.Right+round(0.16*(pp_pz.Printer.PageWidth)),Amountprint+textheight);//凭证日期比例
      2:
       HeadRect:=Rect(headrect.Right,Amountprint,headrect.Right+round(0.14*(pp_pz.Printer.PageWidth)),Amountprint+textheight);//帐套号比例
      3:
       HeadRect:=Rect(headrect.Right,Amountprint,headrect.Right+round(0.2*(pp_pz.Printer.PageWidth)),Amountprint+textheight);//凭证号比例
      4:
       HeadRect:=Rect(headrect.Right,Amountprint,headrect.Right+round(0.1*(pp_pz.Printer.PageWidth)),Amountprint+textheight);//分页数号比例
    end;
    pp_pz.Printer.Canvas.TextOut(Headrect.left,headrect.top,pageheader[count]);
  end;
end;

5、打印表格头

procedure TF_mxzprint.printdetailheader(detailheader: Tstrings);
var
  drect,srect,jrect:Trect;
begin
    pp_pz.Printer.Canvas.Font.Name:='宋体';
    pp_pz.Printer.Canvas.Font.Color:=clblack;
    pp_pz.Printer.Canvas.Font.Size:=9;
    pp_pz.Printer.Canvas.Font.Style:=[];
    gettextinfo;
    Amountprint:=Amountprint+textheight;
    pp_pz.Printer.Canvas.Font.Size:=11;
    drect:=rect(PageRect.Left,Amountprint,PageRect.Left+round(0.3*(PageRect.Right-PageRect.Left)),Amountprint+2*textheight);
    drawtext(pp_pz.Printer.Canvas.handle,pchar('摘   要'),length('摘  要'),drect,DT_center or  DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);
    addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);

    drect:=rect(drect.right,drect.Top,drect.right+round(0.4*(PageRect.Right-PageRect.Left)),srect.Bottom);
    drawtext(pp_pz.Printer.Canvas.handle,pchar('科目名称'),length('科目名称'),drect,DT_center or  DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);
    addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
    drect:=rect(drect.right,drect.Top,drect.right+round(0.15*(PageRect.Right-PageRect.Left)),srect.Bottom);
    drawtext(pp_pz.Printer.Canvas.handle,pchar('借方金额'),length('借方金额'),drect,DT_center or  DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);

    addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]);
    drect:=rect(drect.right,drect.Top,drect.right+round(0.15*(PageRect.Right-PageRect.Left)),srect.Bottom);
    addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
    drawtext(pp_pz.Printer.Canvas.handle,pchar('贷方金额'),length('贷方金额'),drect,DT_center or  DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);

    addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]);
    Amountprint:=amountprint+drect.Bottom-drect.Top;//+textheight;
end;

5、打印表格内容

(与上面相似,代码太多,略。。。)

6、打印汇总栏内容(代码较多,而且也相似,略)

7、执行打印功能

  pp_pz.Printer.BeginDoc;
  依次打印标题、打印、表头等

  PolyPolyline(pp_pz.Printer.Canvas.Handle,PolyPolyPoints.List^,PolyLengths.List^,PolyLengths.Count);  pp_pz.Printer.EndDoc;

 

关键:就两个函数PolyPolyline和DrawText而已!

上一篇:组件开发方式 人气:5333
下一篇:用XML做为数据存贮格式 人气:3808
浏览全部Delphi的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐