1.回调函数其实就是通过函数指针进行调用函数的,具体使用例子如下
a) 定义回调函数类型
type
THDFunction=function(k:integer;sExam:string):integer; stdcall;
b) 回调函数的实现
Function HdFunExample(k:integer;sExam:string):integer; stdcall;
Begin
if k=1226 then
ShowMessage(sExam);
End;
c) 回调函数的调用
i) 定义调用回调函数的函数
function TForm1.DyHdFunExample(HdFun:THDFunction;I:Integer;str:string):boolean;
begin
HdFun(i,str);
end;
ii)调用回调函数
procedure TForm1.btn7Click(Sender: TObject);
begin
DyHdFunExample(@HdFunExample,1226,'yes');
end;