[英]Application executes but sometimes fails to show
This is the project source:这是项目源:
Application.Initialize;
Application.MainFormOnTaskbar := False;
Application.ShowMainForm := False;
Application.CreateForm(TMain_Form, Main_Form);
Application.CreateForm(TData_Module, Data_Module);
Application.CreateForm(TForm5, Form5);
Login;
Application.Run;
Order of creation is : Main_Form,Data_Module,Form5创建顺序是: Main_Form,Data_Module,Form5
Uniconnection timeout is 30 seconds.取消连接超时为 30 秒。
I am connecting to SQL Server .我正在连接到 SQL Server 。
And this I have in my mainForm :这在我的 mainForm 中有:
procedure Login;
begin
with TUniConnectDialog.Create(nil) do
try
try
Application.MainForm.Hide;
if not Data_Module.UniConnectDialog1.Execute then
Application.Terminate
else
Application.MainForm.Show
finally
Free;
end;
except
on E : Exception do begin
ShowMessage('Exception class name = '+E.ClassName);
ShowMessage('Exception message = '+E.Message);
end;
end;
end;
And yet, sometimes my connect dialog fails to show and the application runs silently in the background.I have to use Windows Task Manager to end it.然而,有时我的连接对话框无法显示,应用程序在后台静默运行。我必须使用 Windows 任务管理器来结束它。
I tried using eureka to debug it but it fails to show me any error.我尝试使用 eureka 调试它,但它没有显示任何错误。 Application executes but fails to show.应用程序执行但未能显示。 This happens maybe in 3 out of 10 cases.这可能发生在十分之三的情况下。 Now I cant figure out what am I doing wrong here.现在我无法弄清楚我在这里做错了什么。
Edit:编辑:
procedure Login;
begin
with Data_Module.UniConnectDialog1.Create(nil) do
try
Application.MainForm.Hide;
if not Data_Module.UniConnectDialog1.Execute then
Application.Terminate
else
Application.MainForm.Show
finally
// Free;
end;
end;
EDIT 2: This does not work either.编辑 2:这也不起作用。
This is not a complete solution (or may be - hard to tell) but corrects the errors in the edit of the main question.这不是一个完整的解决方案(或者可能 - 很难说),但纠正了主要问题编辑中的错误。 I couldn't do it in comments, unfortunately.不幸的是,我无法在评论中做到这一点。
procedure Login;
begin
// with Data_Module.UniConnectDialog1.Create(nil) do
// 1) Don't use 'with' - it just creates ambiguity
// 2) You probably don't need to create the dialog
// 3) If you do the format should be:
// Data_Module.UniConnectDialog1 := TUniConnectDialog.Create(???)
try
Application.MainForm.Hide;
if not Data_Module.UniConnectDialog1.Execute then
Application.Terminate
else
Application.MainForm.Show
finally
// Free;
end;
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.