//A method as a parameter to another method, which is called a callback method, is used to call the callback functiontypeTfuntype =function(I:integer): Integer;{Declaring a method type}functionMyfun (I:integer): Integer;{Establish a type-compatible function}beginResult: = i*2;End;{function as argument, define a function}functionMyTest (X:integer; F:tfuntype): Integer;beginResult: = F (x);End;{test}procedureTform1.button1click (Sender:tobject);varFun:tfuntype;{Declare a tfuntype variable}I:integer;beginFun: = Myfun;{Let the method variable fun point to a method that is compatible with its type}{test fun; Fun is a method variable, and now to execute that method, it can be used as that method.}I: = Fun (4); ShowMessage (IntToStr (i));//8{Use fun as a parameter; use function as a parameter, this is the callback function}I: = MyTest (4, fun); ShowMessage (IntToStr (i));//8End;
Http://www.cnblogs.com/del/archive/2008/01/15/1039476.html
The essence of the callback function is to treat the function as a parameter (first define the function type)