TMainForm = class(TForm)
procedure ButtonClick(Sender: TObject);
...
end;
var
MainForm: TMainForm;
OnClick: TNotifyEvent
we could make the following assignment.
OnClick := MainForm.ButtonClick;
Two procedural types are compatible if they have
the same calling convention,
the same return value (or no return value), and
the same number of parameters, with identically typed parameters in corresponding positions. (Parameter
names do not matter.)
Procedure pointer types are always incompatible with method pointer types. The value nil can be assigned to any
procedural type.
Nested procedures and functions (routines declared within other routines) cannot be used as procedural values, nor
can predefined procedures and functions. If you want to use a predefined routine like
Length
as a procedural value,
write a wrapper for it:
function FLength(S: string): Integer;
begin
Result := Length(S);
end;
Dostları ilə paylaş: