delphi7在窗口1自定义了一个过程a在窗口2如何调用过程a,能不能举个例子啦,先谢谢各位兄弟姐妹啦

解决方案 »

  1.   

    引用一下单元文件就可以用了,还有一个你这个过程一定要写在公有区.

    unit1type
       TForm1 = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
        function GetIntValue(i:integer):String;
      end;var
      Form1: TForm1;implementation{$R *.dfm}function  TForm1.GetIntValue(i:integer):String;
    begin
      Result := IntToStr(i);
    end;end.unit2type
       TForm2 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
        
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation
    uses Unit1; //主要是这里引用
    {$R *.dfm}procedure TForm2.Button1Click(Sender: TObject);
    var
      
    begin
      if Form1<>nil then
      begin
        Edit1.text := Form1.GetIntValue(5):
      end;
    end;end.
      

  2.   

    把窗口1的过程a放在public下面在窗口2的implementation下面uses 窗口1单元;