safezone

  易飞的报表打印方向(横向和纵向)是取自默认打印机的设置,所以你会发现如果系统中没有默认打印机的话易飞是无法设计报表的。有客户反映有的报表格式比较固定(横向),由于操作繁琐故没有必要每次都把纸张的方向从纵向设置为横向。

  我们可以在设计报表ReportViewer元件对这些报表作业时把打印机临时设为横向,待退出处理后再恢复回来。实现代码如下:

Code
public
FChange: Boolean;
。。。。。。
procedure TfrmReportViewer.FormShow(Sender: TObject);
var

ADevice, ADriver, APort:
array[0..255] of Char;
DeviceHandle: THandle;
DevMode: PDeviceMode;
begin

//^_^ 20080911 ADD BY ==start 设置为横向
FChangeProperty :
=
False;

If FReportID
= \'COPR01\'
THEN
Begin
{

方法一:用的时候把弹出窗体去掉,直接确认即可
ShellExecute(0, \'OPEN\', PChar(\'D:\Conductor70\C_Dsbin\HP_A4_H.reg\'), nil, nil, SW_SHOWNORMAL);
WinExec(PChar(\'D:\Conductor70\C_Dsbin\HP_A4_H.reg\'), 1);
}
//
方法二:
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;
Printer.SetPrinter(ADevice, ADriver, APort, DeviceHandle);
GlobalUnLock(DeviceHandle);
end
;
end
;
FormatChange;
RepaintArea(
0
, ToolBar.Height, VScrollBar.Left, HScrollBar.Top);

FChangeProperty :
=
True;
End;
//^_^ 20080911 ADD BY ==end


inherited;

end
;


procedure TfrmReportViewer.FormClose(Sender: TObject;var
Action: TCloseAction);
var

ADevice, ADriver, APort:
array[0..255] of Char;
DeviceHandle: THandle;
DevMode: PDeviceMode;
begin

//^_^ 20080911 ADD BY ==start 设置为纵向
If FChange THEN
Begin
//
方法一:用时候去掉确认窗
//ShellExecute(0, \'OPEN\', PChar(\'D:\Conductor70\C_Dsbin\HP_A4_L.reg\'), nil, nil
, SW_SHOWNORMAL);

//
方法二:
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_PORTRAIT;
Printer.SetPrinter(ADevice, ADriver, APort, DeviceHandle);
GlobalUnLock(DeviceHandle);
end
;
end
;

End;
//^_^ 20080911 ADD BY ==end


WriteTransferDataIni([
is
_ShowSetting]);
Disconnect;
// if ((FReportSource= rs_Leader)or(FReportSource= rs_VarLeader))then

if (FReportSource= rs_Leader) then
Action:
= caFree
else Action:=
caHide;
end;

分类:

技术点:

相关文章:

  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2022-01-10
  • 2021-10-07
猜你喜欢
  • 2021-11-22
  • 2021-10-20
  • 2022-01-20
  • 2021-12-15
  • 2021-09-04
  • 2021-11-18
相关资源
相似解决方案