我想用quickReport 3.09 把报表设置成A3纸打印(用代码动态实现)(80分)

  • 主题发起人 主题发起人 xhqing
  • 开始时间 开始时间
X

xhqing

Unregistered / Unconfirmed
GUEST, unregistred user!
我想用代码动态实现设置成A3纸张打印,quickReport 的quickrep1组件的页面属性就设置到了,就是系统打印机的纸张属性没有设置到,我分别尝试用了以下三个WindowsAPI调用都无济于事,请您帮忙,万分感谢:(QuickReport的版本为3.09+Delphi7,不知QuickReport 4.06有没有类似问题)
quickrep1.Page.Length:=297;
quickrep1.Page.Width :=420;
quickrep1.Page.Orientation:=poPortrait;
qrlabel2.Caption:='纸张规格: '+inttostr(round(quickrep1.Page.Width))+' × '+inttostr(round(quickrep1.Page.Length));
implementation
Procedure SetPage(pagewidth,pageheight:real);
var
Device : array[0..cchDeviceName-1] of Char;
Driver : array[0..(MAX_PATH-1)] of Char;
Port : array[0..32]of Char;
hDMode : THandle;
pDMode : PDevMode;
begin
Printer.GetPrinter(Device,Driver,Port,hDMode);
// 获取打印机DevMode 结构的句柄值,存放在hDMode 中
if hDMode <> 0 then

begin

pDMode := GlobalLock(hDMode);
// 获取指向打印机DevMode 结构的指针
if pDMode <> nil then

begin

pDMode^.dmPaperSize := 256;
// 如果要将当前打印机纸张变为自定义 dmPaperSize 必须设置成256
pDMode^.dmPaperLength := round(pageheight*10);
pDMode^.dmPaperWidth := round(pagewidth*10);
pDMode^.dmFields := pDMode^.dmFields or DM_PAPERSIZE;

pDMode^.dmFields :=pDMode^.dmFields or DM_PAPERLENGTH;

pDMode^.dmFields :=pDMode^.dmFields or DM_PAPERWIDTH;
//以上三条语句是对相应的dmFields 成员进行置位。
ResetDC(Printer.Handle,pDMode^);
// 设置打印机设备环境句柄的值
GlobalUnlock(hDMode);

end;

end;

end;


procedure PreparePrinter;
var
aDevice: array[0..CCHDEVICENAME-1] of Char;

aDriver: array[0..MAX_PATH-1] of Char;

aPort: array[0..31] of Char;

hDevMode: THandle;

pDevMode: PDeviceMode;

begin

// 获取打印机DeviceMode的句柄
Printer.GetPrinter(aDevice, aDriver, aPort, hDevMode);

if hDevMode <> 0 then

begin

// 获取指向DeviceMode的指针
pDevMode := GlobalLock(hDevMode);

if pDevMode <> nil then

begin

pDevMode^.dmPaperSize := DMPAPER_USER;

pDevMode^.dmPaperLength := 2970;
pDevMode^.dmPaperWidth := 4200;
pDevMode^.dmFields := pDevMode^.dmFields or DM_PAPERSIZE;

pDevMode^.dmFields := pDevMode^.dmFields or DM_PAPERLENGTH;

pDevMode^.dmFields := pDevMode^.dmFields or DM_PAPERWIDTH;

ResetDC(Printer.Handle, pDevMode^);

GlobalUnlock(hDevMode);

end;

end;

end;


procedure myset;
var
ADevice, ADriver, APort: array[0..255] of Char;

DeviceHandle: THandle;

DevMode: PDeviceMode;

begin
//初始化打印机
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

DevMode := GlobalLock(DeviceHandle);

if DeviceHandle <> 0 then

begin

with DevMode^ do

begin

dmFields := dmFields or DM_ORIENTATION;

//在下面这里设置打印方向
dmOrientation := DMORIENT_LANDSCAPE;
//DMORIENT_PORTRAIT
dmPaperSize := DMPAPER_A3;
Printer.SetPrinter(ADevice, ADriver, APort, DeviceHandle);

GlobalUnLock(DeviceHandle);

end;

end;
end;

{$R *.dfm}
 
听说升級quickreport至3.62後,自定義正常。
谁有quickreport3.62给我发一份:xhwgq1001@yahoo.com.cn,万分感谢!
因为for D7 http://www.delphifans.com/down_view.asp?id=291
for D6 http://www.delphifans.com/down_view.asp?id=295
http://www.playicq.com/datanew/qr362profd7.exe
http://61.132.118.185:8080/dispdocnew.php?t=&id=3454
这四几个没一个现在能下载,麻烦哪位热心朋友帮一下,在此我先谢过了!
 
到2ccc.com去找一下,我以前好象看到过。
 
在www.2ccc.com有(报表),
升級quickreport至3.62后已成功解决自定义纸张问题
 
接受答案了.
 

Similar threads

后退
顶部