type tfun=function(a,b):integer;
procedure add(a,b):integer;
begin
  add := a+b;
end;
function calc(fun:tfun;a:integer;b:integer):integer;
begin
  calc = fun(a,b);
end;//
calc(add);
也许可以

解决方案 »

  1.   

    api 函数里有很多就有回调函数的参数,你可以去查查;方式和wf_z的声明方式相同,用type
    不过我觉得他的有错
      

  2.   

    type tfun=function(a,b):integer;
    这里错了吧?应该是
    type tfun=function(integer;integer):integer;
    声明的是函数或者过程的参数的类型,而不是名字。以上假设是两个integer变量。其实看看那些delphi事件的help就行了,事件帮助里有写着事件的定义代码,照着写就行了。哦,还有。楼上的例子中,calc的调用方法是: result=calc(@add,1,1)。要用符号“@”得到add的地址作为参数。
      

  3.   

    打开delphi看了一下,才发现自己也错了,嘻嘻。应该是
    type TFun=function(a:integer;b:integer):integer;如果是类的方法,要在尾部加上of object.详细看Delphi help 的 Procedural types页
      

  4.   

    实际上,我觉得你打开delphi得源文件,看一下,能有很多启发
    源代码种有很多地方都用了回吊函数
      

  5.   

    定义一个FUNCTION类型,然后按指针调用.