怎么样调用其它窗体的过程?(100分)

  • 主题发起人 主题发起人 mongxing0
  • 开始时间 开始时间
M

mongxing0

Unregistered / Unconfirmed
GUEST, unregistred user!
比如,我在unit1定义好了,想在unit2调用
随便再一下,我这样定义 procedure loadtv,算不算是定义一个过程?
小弟不才,基础不是很好
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;
type
TForm_main = class(TForm)
procedure loadtv; //加载treeview
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_main: TForm_main;
implementation
{$R *.dfm}
procedure TForm_main.loadtv;
begin
......
end;
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;
type
TForm_main = class(TForm)
procedure loadtv; //加载treeview
private
{ Private declarations }
public
{ Public declarations }
procedure loadtv;
end;
var
Form_main: TForm_main;
implementation
{$R *.dfm}
procedure TForm_main.loadtv;
begin
......
end;
/////////////////////////////////////
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;
type
TForm2= class(TForm)
procedure loadtv; //加载treeview
private
{ Private declarations }
public
{ Public declarations }
procedure loadtv;
end;
var
Form2: TForm2;
implementation
uses unit1;
{$R *.dfm}
procedure TForm2.loadtv;
begin
Form_main.loadtv;
end;
 
把这个loadtv过程写到public里
在unit2的implementation段里uses这个unit1,然后就可以调用了,unit1.loadtv
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
798
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
848
SUNSTONE的Delphi笔记
S
后退
顶部