问题描述
从主窗体显示辅助窗体,从第二窗体显示第三窗体时,然后关闭两个窗体都会导致主窗体失去焦点。
When showing a secondary form from the main form and from the second form showing a third form and then closing both forms will cause the main form to lose focus.
在XP SP3中使用Delphi 2009
Using Delphi 2009 with XP SP3
这是我重现此问题的步骤:
Here are my steps for reproducing the problem:
- 创建新的VCL表单应用程序
- 将按钮拖动到创建的表单上
- 在点击处理程序中,创建一个新的TForm1并显示它
运行程序。单击按钮以显示第二个表单。单击第二个表单上的按钮以创建第三个表单。关闭两个新表单时,主表单将失去焦点。
Run the program. Click the button to show a second form. Click the button on the second form to create a third form. When closing both new forms the main form will lose its focus.
这是按钮单击事件处理程序中的代码:
This is my code in the button click event handler:
// Using Self does not change the results
with TForm1.Create(nil) do
show;
有什么方法可以阻止我的主表单失去焦点吗?
Is there any way to stop my main form from losing focus?
推荐答案
将我的Delphi安装从版本 12.0.3170.16989(无更新)升级到版本 12.0.3420.21218(更新3和4)之后我再也无法重现该问题了。
After upgrading my Delphi installation from version 12.0.3170.16989 (no updates) to version 12.0.3420.21218 (update 3 & 4) I could not reproduce the problem anymore.
似乎是一个已在更新中修复的错误。
Seems like it was a bug that was fixed in the update.
这篇关于关闭辅助delphi表单会导致主表单失去焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!