大家好,近期使用DevExpress,發現我的程式出現很多莫名其妙的問題,舉例其中一個
program Project1;
uses
Forms,
Windows,
Controls,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form2 := TForm2.Create(Application);
if Form2.ShowModal = mrok then
Application.Run
else Application.Terminate;
end.
其中form1中有個image,載入一張png圖,form2類似登陸,在執行完Application.Terminate后會報錯,(access violation....),其余問題都是在這報錯,請問你們遇到過這種情況嗎?怎么解決?
uj5u.com熱心網友回復:
varLoginResult : integer;
begin
Application.Initialize;
Form2 := TForm2.Create(nil);
LoginResult := Form2.ShowModal;
FreeAndNil(Form2);
if LoginResult = mrok then begin
Application.CreateForm(TForm1, Form1);
Application.Run;
end else
Application.Terminate;
end.
uj5u.com熱心網友回復:
登錄界面可不是這樣做的。假設form1是主視窗,form2是登錄視窗
你應該在form1 Create時隱藏自身顯示form2,form2中關倍訓完成登錄后關閉自己顯示form1。
uj5u.com熱心網友回復:
Application.Terminate;
請加上
freeandnil(form2);
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/131918.html
標籤:VCL組件開發及應用
下一篇:求大神 幫忙
