📄 rbreport_interface.pas
字号:
unit rbReport_Interface;
interface
uses
classes,Forms,ppReport,ppDsgner,ppEndUsr,PreviewForm;
type
TAfterLoad = procedure(ppReport:TppReport) of object;
TrbReport_Interface = class(TComponent)
private
{ Private declarations }
FAbout :string;
FppReport :TppReport;
FppDesigner :TppDesigner;
FTemplateName:string;
FModalPreview:boolean;
FModalDesign :boolean;
FRptCaption:string;
FDBName:string;
FSQLText:string;
FDetailSQLText:string;
FSubDetailSQLText:String;
FOnAfterLoadTemplate :TAfterLoad;
FOnFeforeLoadTemplate :TAfterLoad;
FOnAfterPrint :TAfterLoad;
FOnFeforePrint :TAfterLoad;
FAutoData :boolean;
procedure SetppReport(Value: TppReport);
procedure SetppDesigner(Value:TppDesigner);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Preview:boolean;
function Design:boolean;
function Print:boolean;
published
{ Published declarations }
property About :string read FAbout;
property RptCaption:string read FRptCaption write FRptCaption;
property ppReport :TppReport read FppReport write SetppReport;
property ppDesigner :TppDesigner read FppDesigner write SetppDesigner;
property TemplateName:string read FTemplateName write FTemplateName;
property ModalPreview:boolean read FModalPreview write FModalPreview;
property ModalDesign :boolean read FModalDesign write FModalDesign;
property DBName:string read FDBName write FDBName;
property SQLText:string read FSQLText write FSQLText;
property DetailSQLText:String read FDetailSQLText write FDetailSQLText;
property SubDetailSQLText:String read FSubDetailSQLText write FSubDetailSQLText;
property OnAfterLoadTemplate:TAfterLoad read FOnAfterLoadTemplate write FOnAfterLoadTemplate;
property OnFeforeLoadTemplate:TAfterLoad read FOnFeforeLoadTemplate write FOnFeforeLoadTemplate;
property OnAfterPrint:TAfterLoad read FOnAfterPrint write FOnAfterPrint;
property OnFeforePrint:TAfterLoad read FOnFeforePrint write FOnFeforePrint;
property AutoData:boolean read FAutoData write FAutoData;
end;
implementation
//**********************************************************************
//*
//*
//*
//**********************************************************************
constructor TrbReport_Interface.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAbout:='Copyright 2001.10 DFGXSOFT Ver 1.0 Build 1';
FAutoData:=false;
FModalPreview:=true;
FModalDesign :=true;
end;
destructor TrbReport_Interface.Destroy;
begin
inherited Destroy;
end;
function TrbReport_Interface.Preview:boolean;
var
frmPreviewForm: TfrmPreviewForm;
begin
try
frmPreviewForm:=nil;
if AutoData then
begin
frmPreviewForm:=TfrmPreviewForm.CreateAutoForm(Application,DBName,SQLText,DetailSQLText,SubDetailSQLText);//CreateForm(Application.MainForm,FppReport);
FppReport:=frmPreviewForm.TmpReportName;
end;
with FppReport do
begin
if assigned(FOnFeforeLoadTemplate) then
FOnFeforeLoadTemplate(FppReport);
Template.FileName:=FTemplateName;
Template.LoadFromFile;
if assigned(FOnAfterLoadTemplate) then
FOnAfterLoadTemplate(FppReport);
AllowPrintToArchive:=false;
AllowPrintToFile:=true;
if assigned(FOnFeforePrint) then
FOnFeforePrint(FppReport);
if not AutoData then
begin
frmPreviewForm:=TfrmPreviewForm.CreateForm(Application,FppReport);
end;
DeviceType:='Screen';
ShowCancelDialog:=True;
ShowPrintDialog:=true;
PrintToDevices;
if FModalPreview then
begin
try
if Length(RptCaption)<>0 then
frmPreviewForm.Caption:=RptCaption;
frmPreviewForm.FormStyle:=fsNormal;
frmPreviewForm.ShowModal;
except
end;
end else
begin
//if Application.MainForm.FormStyle=fsMDIForm then
//frmPreviewForm.ParentWindow:=Application.MainForm.Handle;
if Length(RptCaption)<>0 then
frmPreviewForm.Caption:=RptCaption;
frmPreviewForm.FormStyle:=fsMDIChild;
frmPreviewForm.Show;
end;
if assigned(FOnAfterPrint) then
FOnAfterPrint(FppReport);
Result:=true;
end;
except
Result:=false;
end;
end;
function TrbReport_Interface.Design:boolean;
var
frmPreviewForm: TfrmPreviewForm;
begin
try
if AutoData then
begin
frmPreviewForm:=TfrmPreviewForm.CreateAutoForm(Application,DBName,SQLText,DetailSQLText,SubDetailSQLText);
FppReport:=frmPreviewForm.TmpReportName;
FppDesigner:=frmPreviewForm.TmpDesigner;
end;
with FppReport do
begin
if assigned(FOnFeforeLoadTemplate) then
FOnFeforeLoadTemplate(FppReport);
Template.FileName:=FTemplateName;
Template.LoadFromFile;
if assigned(FOnAfterLoadTemplate) then
FOnAfterLoadTemplate(FppReport);
if not AutoData then
begin
frmPreviewForm:=TfrmPreviewForm.CreateForm(Application,FppReport);
FppDesigner :=frmPreviewform.TmpDesigner;
end;
DeviceType:='Screen';
ShowCancelDialog:=True;
ShowPrintDialog:=true;
end;
with FppDesigner do
begin
if Length(Caption)<>0 then Caption:=Caption;
BringToFront;
if not FModalDesign then
show
else
ShowModal;
Result:=True;
end;
except
Result:=false;
end;
end;
function TrbReport_Interface.Print:boolean;
var
frmPreviewForm: TfrmPreviewForm;
begin
try
frmPreviewForm:=nil;
if AutoData then
begin
frmPreviewForm:=TfrmPreviewForm.CreateAutoForm(Application.MainForm,DBName,SQLText,DetailSQLText,SubDetailSQLText);//CreateForm(Application.MainForm,FppReport);
frmPreviewForm.Hide;
FppReport:=frmPreviewForm.TmpReportName;
end;
with FppReport do
begin
if assigned(FOnFeforeLoadTemplate) then
FOnFeforeLoadTemplate(FppReport);
Template.FileName:=FTemplateName;
//Template.DatabaseSettings.Name:=FTemplateName;
Template.LoadFromFile;
//Template.Load;
if assigned(FOnAfterLoadTemplate) then
FOnAfterLoadTemplate(FppReport);
AllowPrintToArchive:=false;
AllowPrintToFile:=true;
if assigned(FOnFeforePrint) then
FOnFeforePrint(FppReport);
DeviceType:='Printer';
ShowCancelDialog:=True;
ShowPrintDialog:=true;
//PrintToDevices;
Print;
if assigned(FOnAfterPrint) then
FOnAfterPrint(FppReport);
frmPreviewForm.Close;
Result:=true;
end;
except
Result:=false;
end;
end;
//**********************************************************************
procedure TrbReport_Interface.SetppReport(Value: TppReport);
begin
if FppReport<>Value then
FppReport:=Value;
end;
procedure TrbReport_InterFace.SetppDesigner(Value: TppDesigner);
begin
if FppDesigner<>Value then
FppDesigner:=Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -