还是打印缩放的问题:请打印高手看看我的这段 有关缩放的 代码,给点宝贵意见!(100分)

  • 主题发起人 福利彩票
  • 开始时间

福利彩票

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.BitBtn1Click(Sender: TObject);
var ADevice,ADriver,APort:array[0..255] of Char;
DeviceHandle:THandle;
DevMode:pDeviceMode;
//A Pointer to a TDeviceMode structure
Printer : TPrinter;
begin
{ First obtain a handle to the TPrinter's DeviveMode structure
}
Printer.GetPrinter(ADevice,ADriver,APort,DeviceHandle);
{ If DeviceHandle is still 0,then
the driver was not loaded,Set
the printer index to force the printer driver to load making
the handle available
}
if DeviceHandle = 0 then
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(ADevice,ADriver,APort,DeviceHandle);
end;
{ If DeviceHandle is still 0,then
an error has occurred.Otherwise,
use GlobalLock() to get a pointer to the TDeviceMode structure
}
if DeviceHandle = 0 then
Raise Exception.Create('Could Not to the TDeviceMode structure')
else
DevMode := GlobalLock(DeviceHandle);
{ !!Code to use the DevMode structure goes here!!}
{ 注意:必须先设置dmFields字段来指定将要初始化的
TDeviceMode结构的成员,然后才能对他进行初始化。
}
with DevMode^do
begin
// '***'
dmFields := dmFields or DM_SCALE;
dmScale := 50;
{ 页的实际输出尺寸是物理尺寸与TDeviceMode.dmScale得值的乘积再除以100。
所以,要将打印输出(文本和图形)缩小为原来的一半,可以把dmScale设为50。
}
end;

try
QRep.Print;
Printer.Free ;
except
Qrep.free;
end;
if not DeviceHandle = 0 then
GlobalUnlock(DeviceHandle);
end;

/* 现在的问题是:没运行到// '***' 处就出错了,我也没办法了,请高手指教!*/
 
没有看你的代码,但建议你用图元文件,那样操作回简单一点
 
x_coffee 你好
图元文件我不会用,但我希望你能告诉我 缩放打印的思路,谢谢了。
 
好像要改变映射模式才行的吧,具体的我也不太清楚。这个问题我一直关注
 
出什么错误,代码没什么问题,这基本上就是从书上拷过来的吧。
 
呵呵,就是用矢量图么。
图形单元中TMeta开头的那几个类就是矢量图的封装。
矢量图使用函数来描绘图形,所以在缩放时不会有损失
 
顶部