吴
吴向球
Unregistered / Unconfirmed
GUEST, unregistred user!
在Win98中改变默认打印机的属性
问题是这样的:
现在欲打印一个报表,但是纸张大小为自定义,大概width为254 millimeters,
length 为260 millimeters,并且打印控件为QuickReport,如果不改变打印机的纸张
大小属性就不能打出来,在改变了属性之后就搞定了。但是现在想在程序中改变,
在打印完成之后又再改回来。
用下面的语句实现:
//得到纸张的尺寸
Printer.PrinterIndex ;
//选择默认的打印机
if ADeviceMode = 0 then
begin
Printer.GetPrinter(ADevice,ADriver,APort,ADeviceMode);
end;
if ADeviceMode <> 0 then
begin
DevMode := GlobalLock(ADeviceMode);
try
DevMode^.dmFields :=DevMode^.dmFields or DM_PAPERSIZE;
ASize := DevMode^.dmPaperSize ; //将打印尺寸给一全局变量
finally
GlobalUnlock(ADeviceMode);
end;
end
//更改纸张的尺寸
if ADeviceMode = 0 then
begin
Printer.GetPrinter(ADevice,ADriver,APort,ADeviceMode);
end;
if ADeviceMode <> 0 then
begin
DevMode := GlobalLock(ADeviceMode);
try
DevMode^.dmFields :=DevMode^.dmFields or DM_PAPERSIZE;
DevMode^.dmPaperSize := $100 ; //改为自定义纸张大小
// DevMode^.dmPaperLength := 260 ;
// DevMode^.dmPaperWidth := 254 ;
finally
GlobalUnlock(ADeviceMode);
end;
end
//恢复纸张的尺寸
if ADeviceMode = 0 then
begin
Printer.GetPrinter(ADevice,ADriver,APort,ADeviceMode);
end;
if ADeviceMode <> 0 then
begin
DevMode := GlobalLock(ADeviceMode);
try
DevMode^.dmFields :=DevMode^.dmFields or DM_PAPERSIZE;
DevMode^.dmPaperSize := ASize; //恢复默认的设置
finally
GlobalUnlock(ADeviceMode);
end;
end
请问这样做对不对:
如果正确,为什么看不到效果;
如果不正确,应该怎么样写??请各位不赐吝教!!!
问题是这样的:
现在欲打印一个报表,但是纸张大小为自定义,大概width为254 millimeters,
length 为260 millimeters,并且打印控件为QuickReport,如果不改变打印机的纸张
大小属性就不能打出来,在改变了属性之后就搞定了。但是现在想在程序中改变,
在打印完成之后又再改回来。
用下面的语句实现:
//得到纸张的尺寸
Printer.PrinterIndex ;
//选择默认的打印机
if ADeviceMode = 0 then
begin
Printer.GetPrinter(ADevice,ADriver,APort,ADeviceMode);
end;
if ADeviceMode <> 0 then
begin
DevMode := GlobalLock(ADeviceMode);
try
DevMode^.dmFields :=DevMode^.dmFields or DM_PAPERSIZE;
ASize := DevMode^.dmPaperSize ; //将打印尺寸给一全局变量
finally
GlobalUnlock(ADeviceMode);
end;
end
//更改纸张的尺寸
if ADeviceMode = 0 then
begin
Printer.GetPrinter(ADevice,ADriver,APort,ADeviceMode);
end;
if ADeviceMode <> 0 then
begin
DevMode := GlobalLock(ADeviceMode);
try
DevMode^.dmFields :=DevMode^.dmFields or DM_PAPERSIZE;
DevMode^.dmPaperSize := $100 ; //改为自定义纸张大小
// DevMode^.dmPaperLength := 260 ;
// DevMode^.dmPaperWidth := 254 ;
finally
GlobalUnlock(ADeviceMode);
end;
end
//恢复纸张的尺寸
if ADeviceMode = 0 then
begin
Printer.GetPrinter(ADevice,ADriver,APort,ADeviceMode);
end;
if ADeviceMode <> 0 then
begin
DevMode := GlobalLock(ADeviceMode);
try
DevMode^.dmFields :=DevMode^.dmFields or DM_PAPERSIZE;
DevMode^.dmPaperSize := ASize; //恢复默认的设置
finally
GlobalUnlock(ADeviceMode);
end;
end
请问这样做对不对:
如果正确,为什么看不到效果;
如果不正确,应该怎么样写??请各位不赐吝教!!!