在Delphi中如何控制打印份数?(在线等待!)

star_of_light 2002-10-25 09:50:05
在Delphi中如何控制打印份数?我的源代码如下:
var
App,Item:OleVariant;
Fn:String;
ADevice,ADriver,APort:Array[0..255] Of Char;
DeviceHandle:THandle;
DevMode:PDeviceMode;
Printer:TPrinter;
begin
If PrintDialog.Execute then
begin
Printer:=TPrinter.Create;
Fn:=ExtractFilePath(Application.ExeName);
Fn:=Fn+'Doc\temp.doc';
app:=CreateOleObject('Word.Application');
app.Application.Options.CreateBackup:=False;
App.Application.Options.SaveNormalPrompt:=False;
App.Application.Options.SavePropertiesPrompt:=False;
Item:=1;
If (Not dm.Data.Prints.FieldByName('PrintImage').IsNull) and (dm.Data.Pacts.FieldByName('Act').AsBoolean) then
begin //盖章并打印合同
TBlobField(dm.Data.Pacts.FieldByName('Pact')).SaveToFile(Fn);
Sleep(50);
app.application.documents.open(Fn);
ClipBoard.Clear;
Photo.CopyToClipboard;
app.Application.Documents.Item(Item).Sentences.Last.Paste;
end
Else
begin
ShowMessage('不存在指定的章或者该合同是无效合同!');
Exit;
end;
Printer.GetPrinter(ADevice,ADriver,APort,DeviceHandle);
If DeviceHandle=0 then
begin
Printer.PrinterIndex:=Printer.PrinterIndex;
Printer.GetPrinter(ADevice,ADriver,APort,DeviceHandle);
end;
If DeviceHandle=0 then
Raise Exception.Create('不能初始化打印驱动程序,打印失败!')
Else
begin
DevMode:=GlobalLock(DeviceHandle);
With DevMode^ do
begin
dmFields:=dmFields Or DM_COPIES;
dmCopies:=PrintDialog.Copies;
end;
App.Application.Documents.Item(Item).PrintOut;
end;
Sleep(9600);
ClipBoard.Clear;
App.Application.Documents.Item(Item).Saved:=True;
App.Quit;
DeleteFile(Fn);
GlobalUnlock(DevMode);
end;
end;
可是,为什么控制不了呢?希望各位高手赐教!
...全文
144 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
huyalin 2002-10-25
  • 打赏
  • 举报
回复
使用PrintSetup的对话框控件
star_of_light 2002-10-25
  • 打赏
  • 举报
回复
各位大侠,小弟正等着你们结帖呢。
star_of_light 2002-10-25
  • 打赏
  • 举报
回复
To genphone_ru :
能不能详细一些,最好给个例子。谢谢!
票票飞扬 2002-10-25
  • 打赏
  • 举报
回复
这样不行的话用循环来控制吧。应该可行。

5,388

社区成员

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

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