Writing Custom Wizards  编写自定义的向导

 

You can extend FastReport's functionality with the help of custom wizards. FastReport, for example, contains the standard “Report Wizard” which is called from the “File >|New…” menu item.

There are two types of wizards supported by FastReport. The first type includes the wizard already mentioned, called from the “File>New…” menu item. The second one includes wizards that can be called from the “Wizards” toolbar.

The base class for any wizard is “TfrxCustomWizard”, defined in the “frxClass” file.

TfrxCustomWizard = class(TComponent)

Public

Constructor Create(AOwner: TComponent); override;

class function GetDescription: String; virtual; abstract;  //需要实现

function Execute: Boolean; virtual; abstract;   //需要实现

property Designer: TfrxCustomDesigner read FDesigner;

property Report: TfrxReport read FReport;

end;

To write your own wizard inherit from this class and override at least the “GetDescription” and “Execute” methods. The first method returns the wizard name; the second method is called when running the wizard; it must return “True” if the wizard finished successfully and made any changes to the report. While the wizard is running you can access designer and report methods and properties as normal using the “Designer” and “Report” properties.

 

Wizard registration and deletion is performed using the procedures defined in the “frxDsgnIntf” file:

向导的注册用以下方法,声明在frxDsgnIntf文件:

frxWizards.Register(ClassRef: TfrxWizardClass; ButtonBmp: TBitmap;IsToolbarWizard: Boolean = False);

frxWizards.Unregister(ClassRef: TfrxWizardClass);

On registration supply the wizard class name, its picture and whether the wizard is to be placed on the “Wizards” toolbar. If the wizard should be placed on the toolbar the ButtonBmp size must be either 16x16 pixels or 32x32 pixels.

//举例

Let's look at a primitive wizard that will be accessed through the "File>New..." menu item. It adds a new page to a report.

uses frxClass, frxDsgnIntf;

type

TfrxMyWizard = class(TfrxCustomWizard)

public

//需要重写的方法

class function GetDescription: String; override;

function Execute: Boolean; override;

end;

class function TfrxMyWizard.GetDescription: String;

begin

Result := 'My Wizard';

end;

function TfrxMyWizard.Execute: Boolean;

var

Page: TfrxReportPage;

begin

{ lock any drawings in designer }

Designer.Lock;

{ create new page in report }

Page := TfrxReportPage.Create(Report);

{ create unique name for page }

Page.CreateUniqueName;

{ set paper sizes and orientation to defaults }

Page.SetDefaults;

{ update report pages and switch focus to last added page }

Designer.ReloadPages(Report.PagesCount - 1);

end;

 

//注册

var

Bmp: TBitmap;

initialization

Bmp := TBitmap.Create;

{ load picture from resource; of course, it must already be there }

Bmp.LoadFromResourceName(hInstance, 'frxMyWizard');

frxWizards.Register(TfrxMyWizard, Bmp);

finalization

frxWizards.Unregister(TfrxMyWizard);

Bmp.Free;

end.

[翻译]Writing Custom Wizards 编写自定义的向导的更多相关文章

  1. [翻译]Writing Custom Report Components 编写自定义报表组件

    摘要:简单介绍了如何编写一个FastReport的组件,并且注册到FastReport中使用.   Writing Custom Report Components 编写自定义报表组件 FastRep ...

  2. [翻译]Writing Custom Common Controls 编写自定义控件

    摘要:介绍如何编写自定义的控件,用在报表的窗体上(如Edit,Button等)   Writing Custom Common Controls 编写自定义控件 FastReport contains ...

  3. [翻译]Writing Custom DB Engines 编写定制的DB引擎

    Writing Custom DB Engines  编写定制的DB引擎   FastReport can build reports not only with data sourced from ...

  4. [翻译]Writing Component Editors 编写组件的编辑器

    Writing Component Editors  编写组件的编辑器   All common control editors (opened from a control's context me ...

  5. [翻译] Writing Property Editors 编写属性编辑器

    Writing Property Editors 编写属性编辑器   When you select a component in the designer its properties are di ...

  6. (译)Getting Started——1.3.4 Writing a Custom Class(编写自定义的类)

     在开发IOS应用中,当你编写自定义的类时,你会发现很多的特殊场合.当你需要把自定义的行为和数据包装在一起时,自定义的类非常有用.在自定义的类中,你可以定义自己的存储.处理和显示数据的方法. 例如,I ...

  7. django “如何”系列4:如何编写自定义模板标签和过滤器

    django的模板系统自带了一系列的内建标签和过滤器,一般情况下可以满足你的要求,如果觉得需更精准的模板标签或者过滤器,你可以自己编写模板标签和过滤器,然后使用{% load %}标签使用他们. 代码 ...

  8. SpringBoot编写自定义的starter 专题

    What’s in a name All official starters follow a similar naming pattern; spring-boot-starter-*, where ...

  9. Kubernetes 编写自定义 controller

    原文链接:Kubernetes编写自定义controller 来自kubernetes官方github的一张图: 如图所示,图中的组件分为client-go和custom controller两部分: ...

随机推荐

  1. Spinnaker 介绍

    功能: 无论目标环境如何,Spinnaker 部署优势始终如一,它的功能如下: 通过灵活和可配置 Pipelines,实现可重复的自动化部署: 提供所有环境的全局视图,可随时查看应用程序在其部署 Pi ...

  2. python中使用Opencv进行人脸识别

    上一节讲到人脸检测,现在讲一下人脸识别.具体是通过程序采集图像并进行训练,并且基于这些训练的图像对人脸进行动态识别. 人脸识别前所需要的人脸库可以通过两种方式获得:1.自己从视频获取图像   2.从人 ...

  3. 如何获取某个网站的favicon.ico

    http://moco.imooc.com/player/report.html 今天看到这个网站上,左侧的小图片挺好看的,想弄下来,检查源码,也没有看到 <head> <meta  ...

  4. CentOS7.0重置Root的密码 (忘记密码)

    首先进入开启菜单,按下e键进入编辑现有的内核,如下图所示 然后滚动列表,找到ro,将它替换成rw,并加上init=/sysroot/bin/sh,最终变为如下图 然后按CTRL+X进入到单用户模式,在 ...

  5. ValueError: update only works with $ operators

    问题:在执行pymongo的update语句时,提示了ValueError: update only works with $ operators 脚本:db.user.update_one({&qu ...

  6. Ubuntu 分辨率更改 xrandr Failed to get size of gamma for output default

    sudo vim /etc/xorg.conf copy: Section "Monitor" Identifier "Monitor0" VendorName ...

  7. leetcode 196. Delete Duplicate Emails

    # 慢,内连接delete p1 from Person p1, Person p2 where p1.Email=p2.Email and p1.Id>p2.Id delete from Pe ...

  8. 使用jdbc编程实现对数据库的操作以及jdbc问题总结

    1.创建数据库名为mybatis. 2. 在数据库中建立两张表,user与orders表: (1)user表: (2)orders表: 3.创建工程 * 开发环境: * eclipse mars *  ...

  9. windows下 Memcache cpu占用过高

    分析应该是memcache的内存大小还是默认配置,已经满足不了当前的大数据量的需要了,大量的新缓存需要进入,同时大量的旧缓存又需要被淘汰出来,一进一出导致CPU占用过多. 进入注册表,找到:HKEY_ ...

  10. 关于session报错问题。

    刚开始一直报500错误,页面不提示,也没想着去查看日志文件.好几天了,一看日志,发现是这个问题.问了一下,是session的问题. 2017/07/25 16:57:49 [error] 2300#0 ...