当前位置:首页 -> 焦点新闻

在WIN2000/XP下添加自定义纸张的Delphi源代码

2005/1/7 14:41:45       
//增加规格自定义纸张
//PaperName: 自定义纸张名称
//PaperWidth: 纸张的宽度,以0.1mm为单位
//PaperLength: 纸张的高度,以0.1mm为单位
procedure TDM.AddCustomPaper(const PaperName: string; PaperWidth, PaperLength:integer);
var
PrintDevice, PrintDriver, PrintPort : array[0..255] of Char;
hDMode   : THandle;
hPrinter : THandle;
FormInfo : TFormInfo1;
begin
Printer.GetPrinter(PrintDevice, PrintDriver, PrintPort, hDMode);
OpenPrinter(PrintDevice, hPrinter, nil);
if hPrinter = 0 then
raise Exception.Create('联接打印机失败!');

with FormInfo do
begin
Flags := FORM_USER;
pName := PChar(PaperName);
Size.cx := PaperWidth*100;
Size.cy := PaperLength*100;
ImageableArea.Left := 0;
ImageableArea.Top := 0;
ImageableArea.Right := PaperWidth*100;
ImageableArea.Bottom := PaperLength*100;
end;

//修改纸型,如果没有就新增
if not SetForm(hPrinter, PChar(PaperName), 1, @FormInfo) then
AddForm(hPrinter, 1, @FormInfo);

ClosePrinter(hPrinter);
end;

//删除自定义规格纸张
//PaperName: 自定义纸张名称
procedure TDM.DeleteCustomPaper(const PaperName: string);
var
PrintDevice, PrintDriver, PrintPort : array[0..255] of Char;
hDMode   : THandle;
hPrinter : THandle;
begin
Printer.GetPrinter(PrintDevice, PrintDriver, PrintPort, hDMode);
OpenPrinter(PrintDevice, hPrinter, nil);
if hPrinter = 0 then
raise Exception.Create('联接打印机失败!');
DeleteForm(hPrinter, PChar(PaperName));
ClosePrinter(hPrinter);
end;

煤炭网版权与免责声明:

凡本网注明"来源:煤炭网www.coal.com.cn "的所有文字、图片和音视频稿件,版权均为"煤炭网www.coal.com.cn "独家所有,任何媒体、网站或个人在转载使用时必须注明"来源:煤炭网www.coal.com.cn ",违反者本网将依法追究责任。

本网转载并注明其他来源的稿件,是本着为读者传递更多信息的目的,并不意味着本网赞同其观点或证实其内容的真实性。其他媒体、网站或个人从本网转载使用时,必须保留本网注明的稿件来源,禁止擅自篡改稿件来源,并自负版权等法律责任。违反者本网也将依法追究责任。 如本网转载稿件涉及版权等问题,请作者在两周内尽快来电或来函联系。

  • 用手机也能做煤炭生意啦!
  • 中煤远大:煤炭贸易也有了“支付宝”
  • 中煤开启煤炭出口贸易人民币结算新时代
  • 下半年煤炭市场依然严峻
市场动态

网站技术运营:北京真石数字科技股份有限公司、喀什中煤远大供应链管理有限公司、喀什煤网数字科技有限公司

总部地址:北京市丰台区总部基地航丰路中航荣丰1层

京ICP备18023690号-1      京公网安备 11010602010109号


关注中煤远大微信
跟踪最新行业资讯