如果你的过程中用到了窗体上的组件,你可以将该过程声明为窗体的私有(或别的什么)方法。
例如:
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure WriteText(Str:String)
//私有方法
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WriteText(Str: String);
begin
Edit1.Text:=Str
//直接使用Edit1
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
WriteText('Do you know?');
end;