从框架无法将函数引用传递给表单

4

我正在开发一个应用程序,其中包含一个PageControl控件,上面有多个TabSheet选项卡。在每个TabSheet选项卡上,我会放置一些预定义的框架。每个框架中都有一个名为“GetValue”的例程,它将其控件的内容解析为字符串并返回结果。在主窗体(RGMain)中,我有以下代码:

Type
   TGetValueFunction = Function: String;
...   
Private
   fGetValueFunction: TGetValueFunction;
...      
Public
   Property GetValueFunction: TGetValueFunction Write fGetValueFunction;

在每个Frame中,我都有以下内容:
Public
Constructor Create(AQwner: TComponent);
...
Interface
Constructor TBooleanChoiceFrame.Create(AOwner: TComponent);
   Begin
   Inherited Create(AOwner);
   RGMain.GetValueFunction := GetValue; <<<< compile error on this line
   End;

E2009 不兼容类型:'常规过程和方法指针'

除了纠正问题之外,这是否是解决在每个框架中获取GetValue例程访问权限的正确方法?

1个回答

6
如果您想使用类的方法,您需要像这样声明函数类型:
Type
   TGetValueFunction = Function: String of object;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接