新文章 网摘 文章 随笔 日记

Delphi7 窗体构造函数传参

type
  TMyForm = class(TForm)
  private
    FUserName: string;
  public
    constructor Create(AOwner: TComponent; 
        const UserName: string);  reintroduce; overload;
  end;


implementation

constructor TMyForm.Create(AOwner: TComponent; 
        const UserName: string);
begin
  inherited Create(AOwner);
  FUserName := UserName;
end;


//使用:
MyForm := TMyForm.Create(Application, UserName);

https://stackoverflow.com/questions/14033023/pass-parameter-when-creating-a-new-form-in-delphi-sdi

 

https://stackoverflow.com/questions/1758917/delphi-pascal-overloading-a-constructor-with-a-different-prototype

posted @ 2021-02-19 11:49  岭南春  阅读(257)  评论(0)    收藏  举报