翻译|使用教程|编辑:杨鹏连|2021-06-28 09:42:34.010|阅读 184 次
概述:FastReport VCL它提供了可视化模板设计器,可以访问 30 多种格式,并可以部署到云、网站、电子邮件和打印中。本文介绍了FastReport VCL报表类层次结构。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
相关链接:
FastReport VCL是用于 Delphi、C++ Builder、RAD Studio 和 Lazarus 的报告和文档创建 VCL 库。它提供了可视化模板设计器,可以访问 30 多种格式,并可以部署到云、网站、电子邮件和打印中。
TfrxComponent是所有 FastReport 组件的基类。这种类型的对象具有参数,例如坐标、大小、字体、可见性和从属对象的列表。此类还包含允许在流中保存/恢复对象状态的方法。
TfrxComponent = class(TComponent) protected procedure SetParent(AParent: TfrxComponent); virtual; procedure SetLeft(Value: Extended); virtual; procedure SetTop(Value: Extended); virtual; procedure SetWidth(Value: Extended); virtual; procedure SetHeight(Value: Extended); virtual; procedure SetFont(Value: TFont); virtual; procedure SetParentFont(Value: Boolean); virtual; procedure SetVisible(Value: Boolean); virtual; procedure FontChanged(Sender: TObject); virtual; public constructor Create(AOwner: TComponent); override; procedure Assign(Source: TPersistent); override; procedure Clear; virtual; procedure CreateUniqueName; procedure LoadFromStream(Stream: TStream); virtual; procedure SaveToStream(Stream: TStream); virtual; procedure SetBounds(ALeft, ATop, AWidth, AHeight: Extended); function FindObject(const AName: String): TfrxComponent; class function GetDescription: String; virtual; property Objects: TList readonly; property AllObjects: TList readonly; property Parent: TfrxComponent; property Page: TfrxPage readonly; property Report: TfrxReport readonly; property IsDesigning: Boolean; property IsLoading: Boolean; property IsPrinting: Boolean; property BaseName: String; property Left: Extended; property Top: Extended; property Width: Extended; property Height: Extended; property AbsLeft: Extended readonly; property AbsTop: Extended readonly; property Font: TFont; property ParentFont: Boolean; property Restrictions: TfrxRestrictions; property Visible: Boolean; end;
TfrxReportComponent = class(TfrxComponent) public procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); virtual; abstract; procedure BeforePrint; virtual; procedure GetData; virtual; procedure AfterPrint; virtual; function GetComponentText: String; virtual; property OnAfterPrint: TfrxNotifyEvent; property OnBeforePrint: TfrxNotifyEvent; end;绘制对象时调用 Draw 方法。参数如下:
TfrxDialogComponent = class(TfrxReportComponent) public property Bitmap: TBitmap; property Component: TComponent; published property Left; property Top; end;TfrxDialogControl类是编写通用控件的基础类,可以放在报表中的对话窗体上。此类包含大多数常见控件共享的大量常规属性和事件。
TfrxDialogControl = class(TfrxReportComponent) protected procedure InitControl(AControl: TControl); public property Caption: String; property Color: TColor; property Control: TControl; property OnClick: TfrxNotifyEvent; property OnDblClick: TfrxNotifyEvent; property OnEnter: TfrxNotifyEvent; property OnExit: TfrxNotifyEvent; property OnKeyDown: TfrxKeyEvent; property OnKeyPress: TfrxKeyPressEvent; property OnKeyUp: TfrxKeyEvent; property OnMouseDown: TfrxMouseEvent; property OnMouseMove: TfrxMouseMoveEvent; property OnMouseUp: TfrxMouseEvent; published property Left; property Top; property Width; property Height; property Font; property ParentFont; property Enabled: Boolean; property Visible; end;
在编写您自己的自定义控件元素时,您应该从此类继承,将所需的属性转移到“已发布”部分,然后为您的公共控件指定新属性。控制元素的编写将在下一章详细讨论。
TfrxViewclass 是大多数组件的基本类,可以放在报表设计页面上。这种类型的对象具有框架和填充等参数,也可以连接到数据源。大多数 FastReport 标准对象都是从这个类继承而来的。
TfrxView = class(TfrxReportComponent) protected FX, FY, FX1, FY1, FDX, FDY, FFrameWidth: Integer; FScaleX, FScaleY: Extended; FCanvas: TCanvas; procedure BeginDraw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); virtual; procedure DrawBackground; procedure DrawFrame; procedure DrawLine(x, y, x1, y1, w: Integer); public function IsDataField: Boolean; property BrushStyle: TBrushStyle; property Color: TColor; property DataField: String; property DataSet: TfrxDataSet; property Frame: TfrxFrame; published property Align: TfrxAlign; property Printable: Boolean; property ShiftMode: TfrxShiftMode; property TagStr: String; property Left; property Top; property Width; property Height; property Restrictions; property Visible; property OnAfterPrint; property OnBeforePrint; end;此类中定义了以下方法:
TfrxStretcheable = class(TfrxView) public function CalcHeight: Extended; virtual; function DrawPart: Extended; virtual; procedure InitPart; virtual; published property StretchMode: TfrxStretchMode; end;给定类的对象可以被拉伸,也可以在对象在输出页面上找不到空间的情况下“分解”成碎片。同时,对象被零散地显示,直到显示其所有数据。
如果您对FastReport感兴趣,欢迎加入FastReport QQ 交流群:702295239
还想要更多吗?您可以点击阅读【FastReport报表2021最新资源盘点】,查找需要的教程资源。上是FastReport .NET正在慧都网火热销售中!>>查看价格详情
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn
文章转载自: