我試圖在我的主表單啓動時加載表單。我使用ShowModal
。此外,該表單不是自動創建表單,所以我必須先用application.CreateForm
創建它。表單在應用程序的FormCreate事件上創建兩次
我的問題是,當我嘗試在FormCreate
事件中加載表單時,它會加載表單兩次,當我關閉表單時,我的整個應用程序關閉。
這裏是我的代碼:
procedure Tfrm_main.FormCreate(Sender: TObject);
var
username, password : string;
begin
username := ini.ReadString('user','username','');
if username = '' then
begin
application.CreateForm(Tfrm_user,frm_user);
frm_user.ShowModal;
end;
end;
我怎樣才能解決這個問題?謝謝。
*「我必須先用application.CreateForm創建它」* - 您不必。使用'frm_user:= Tfrm_user.Create(Application)',你會沒事的。 – 2014-09-02 21:17:52