procedure gg;
begin
  Application.MessageBox('马迪 ', '晕死ua', MB_OK + MB_ICONINFORMATION);
end;
procedure Test.gg;begin
  Application.MessageBox('我操', '麻痹', MB_OK +
    MB_ICONINFORMATION);end;
procedure Test.KK;
begin
  gg;
end;我想让TEST.KK调用全局的静态过程 !要怎么写呢

解决方案 »

  1.   


    type
      Test2 = class(TObject)
        class procedure gg;
      end;class procedure Test2.gg;
    begin
      Application.MessageBox('马迪 ', '晕死ua', MB_OK + MB_ICONINFORMATION);
    end;procedure Test.gg;
    begin
      Application.MessageBox('我操', '麻痹', MB_OK +
        MB_ICONINFORMATION)
    end;procedure Test.KK;
    begin
      test2.gg;
    end;
      

  2.   

    好像是没有c++里的 ::函数名 的用法
    应该创造selfunit这样的关键字
      

  3.   

    在普通方法声明和实现前冠以class关键字
    type  
    Test2 = class(TObject)     
    class procedure gg;   
    end;   
    class procedure Test2.gg; 
    begin  
    Application.MessageBox('马迪 ', '晕死ua', MB_OK + MB_ICONINFORMATION); 
    end;
    ........
    Test2.gg;  //调用 
      

  4.   


    //如果不想用class过程,也可以给过程起个别名
    type
      TPGG = procedure();
    end;procedure gg;
    begin
      Application.MessageBox('马迪 ', '晕死ua', MB_OK + MB_ICONINFORMATION);
    end;var
      pg:TPGG = gg;
       
    procedure TForm1.gg;
    begin
      Application.MessageBox('我操', '麻痹', MB_OK +
        MB_ICONINFORMATION);
    end;procedure TForm1.KK;
    begin
      pg;
    end;
    // 或者用类似名字空间的方式
    unit Unit2;
    interface
    uses
      Forms;
    procedure gg();implementation
    procedure gg();
    begin
      Application.MessageBox('sdfdsf','fdsfs'); //;
    end;
    end.....unit Unit1;
    type test = class;
      gg;
    end;
    uses unit_1;
    procedure test.gg;
    begin
      Unit2.gg; // 显示给出Unit2
    end;
      

  5.   

    本单元也一样的啊,一个单元内可以定义多个类型的,不指定类型那就是unit内全局的
    unit1.gg; // 单元内全局函数
    unit1.form1.gg; // 单元内的form1类中的成员函数