Unable to pass function link to form from frame

I have an application that I create that has a PageControl parameter with several tabs created, on which I put several predefined frames. Each frame called "GetValue" has a subroutine that analyzes the contents of the controls in a string and returns the result. On the main form (RGMain) I have:

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

In each of the frames, I:

 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 Incompatibility types: "regular procedure and method pointer"

Besides fixing the problem, is this even the right way to solve the problem of accessing the GetValue procedure in each frame?

+4
source share
1 answer

If you want to use class methods, you must declare the type of the function as follows:

 Type TGetValueFunction = Function: String of object; 
+6
source

Source: https://habr.com/ru/post/1437033/


All Articles