有两台打印机A,B
我打印报表1时,用A打印机打印,打印报表2时,用B打印机打印我是这样写的:打印A时,调用SETPRINTER(0)
打印B时,调用SETPRINTER(1)
可是第一次先打报表1时,再打报表2,就总是打到打印机1
如果第一次先打报表2时,再打报表1,就总是打到打印机2
不知是什么问题?procedure TPayFrm.SetPrinter(serno:integer);
var
Mydevice,Mydriver,MyPort:array[0..255] of char;
MyHandle:THandle;
i:integer;
begin
if printer.Printers.Count=1 then exit;
printer.PrinterIndex:=Serno;
Printer.GetPrinter(Mydevice,
MyDriver,
MyPort,
MyHandle);
StrCat(MyDevice,',');
StrCat(MyDevice,MyDriver);
StrCat(MyDevice,',');
StrCat(Mydevice,MyPort);
//write win.ini
WriteProfileString('WINDOWS','DEVICE',Mydevice);
//tell all application that windows ini file has changed ,
//this will cause them all to recheck default printer
SendMessage(HWND_BROADCAST,
WM_WININICHANGE,
0,
LongInt(pChar('windows'))
);end;
我打印报表1时,用A打印机打印,打印报表2时,用B打印机打印我是这样写的:打印A时,调用SETPRINTER(0)
打印B时,调用SETPRINTER(1)
可是第一次先打报表1时,再打报表2,就总是打到打印机1
如果第一次先打报表2时,再打报表1,就总是打到打印机2
不知是什么问题?procedure TPayFrm.SetPrinter(serno:integer);
var
Mydevice,Mydriver,MyPort:array[0..255] of char;
MyHandle:THandle;
i:integer;
begin
if printer.Printers.Count=1 then exit;
printer.PrinterIndex:=Serno;
Printer.GetPrinter(Mydevice,
MyDriver,
MyPort,
MyHandle);
StrCat(MyDevice,',');
StrCat(MyDevice,MyDriver);
StrCat(MyDevice,',');
StrCat(Mydevice,MyPort);
//write win.ini
WriteProfileString('WINDOWS','DEVICE',Mydevice);
//tell all application that windows ini file has changed ,
//this will cause them all to recheck default printer
SendMessage(HWND_BROADCAST,
WM_WININICHANGE,
0,
LongInt(pChar('windows'))
);end;
解决方案 »
- 用Delphi做大型项目如何构架?
- 我只想让form2贴在form1右边,哪错了?
- 祝贺Belphi2006发布,只能放100分,呵呵,再来一贴
- 关于DBGrid的问题,谢谢各位高手了,急!!!!!!!!!!!
- 不明白,Delphi的TFrame结构有什么作用呢,根TPanel有什么区别。
- 求救!小弟刚学DELPHI急啊.pagecontrol 在线等
- 一个关于GetTextBuf的问题?
- 请问有没有类似delphi开发环境里“run”的快捷按钮?
- 怎样在DBGRID中实现象资源管理器中的排序功能?
- interbase的打包问题
- 如何写个用户登陆的线程?
- delphi 中文和数字转16进制问题
把A报表的打印机的配置参数设置为打印1,
把B报表的打印机的配置参数设置为打印2,打印A的时候找到所有的打印机,在其中找到打印机1,
把打印机设置为当前打印机,直接输出就行了。
这些在Delphi的Pinters单元里都有,不用调用WindowsAPI处理的。