FastReport中国社区FastReport联系电话 联系电话:023-68661681

我想在所有的TfrReport组件中使用我的自定义函数,能行吗?

来源:   发布时间:2016-08-08   浏览:3208次

问题描述:我想在所有的TfrReport组件中使用我的自定义函数,能行吗?

解决问题:使OnUserFunction event 句柄作为所有组件的公用句柄。如果你不能做到这一点,你需要创建函数库:

type
TMyFunctionLibrary = class(TfrFunctionLibrary)
public
constructor Create; override;
procedure DoFunction(FNo: Integer; p1, p2, p3: Variant;
var val: Variant); override;
end;

constructor TMyFunctionLibrary.Create;
begin
inherited Create;
with List do
begin
Add('DATETOSTR');
Add('SUMTOSTR');
end;
end;

procedure TMyFunctionLibrary.DoFunction(FNo: Integer; p1, p2, p3: Variant;
var val: Variant);
begin
val := 0;
case FNo of
0: val := My_DateConvertion_Routine(frParser.Calc(p1));
1: val := My_SumConvertion_Routine(frParser.Calc(p1));
end;
end;

要注册函数库,调用
frRegisterFunctionLibrary(TMyFunctionLibrary);
要卸载函数库,调用
frUnRegisterFunctionLibrary(TMyFunctionLibrary);


本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:FastReport控件中文网 [https://www.fastreportcn.com/]
本文地址:https://www.fastreportcn.com/post/1140.html

联系我们
  • 重庆总部 023-68661681
购买
  • sales@evget.com
合作
  • business@evget.com


在线
客服
微信
QQ 电话
023-68661681
返回
顶部