-----------
回调函数的说明:回调函数(callback)是什么? - 知乎 https://www.zhihu.com/question/19801131
----------
-------------
了解一下这个:Delphi 中三种回调函数形式解析 - 码农的笔记 - 博客园 https://www.cnblogs.com/dmqhjp/p/14776209.html
有必要
--------------
----------------------------------------------开发环境-D7
------Unit开始
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ;
type
TFCall=function(i:integer):string; //回调函数类型声明
TForm1 = class(TForm)
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
function GetStr(F:TFCall; i:integer):string;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function FCallBack01(i:integer):string; //回调函数定义
begin
Result:=IntToStr(i)+'100';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage(GetStr(FCallBack01,22));
end;
function TForm1.GetStr(F: TFCall; i:integer): string;
begin
Result:=F(i);
end;
end.
---------------unit结束
-----------Form开始
object Form1: TForm1
Left = 756
Top = 527
Width = 263
Height = 146
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button2: TButton
Left = 64
Top = 40
Width = 75
Height = 25
Caption = 'Button2'
TabOrder = 0
OnClick = Button2Click
end
end
---------------Form结束
------------------------------------------------
另一个:Delphi中回调函数的简单例子 - 码农的笔记 - 博客园 https://www.cnblogs.com/dmqhjp/p/14772029.html