FormCreate 和 Hide 之后不会触发 FormShow 事件;不隐藏任务栏上的图标
我刚刚在我的 Delphi 应用程序中发现了一个奇怪的错误。当我运行应用程序时,任务栏显示该图标,但我必须按下它才能显示表单。通过在OnShow事件中设置断点,我发现当我单击任务栏上的图标时,OnShow事件被触发。
另外,当我使用 Hide;
时,表单会隐藏,但任务栏图标不会消失,但是当我单击它时,表单不会再次显示(这是重点,但任务栏图标隐藏时不应该存在)。
这是我的项目文件源,以防可能与之有关:
var
PreviousHandle : THandle;
begin
PreviousHandle := FindWindow('TfrmMain',APP_CAPTION);
if PreviousHandle = 0 then
Begin
Application.Initialize;
// So my Log and Mainform can overlap each other
Application.MainFormOnTaskbar := False;
Application.Title := 'MyApp';
Application.CreateForm(TfrmMain, frmMain);
Application.CreateForm(TfrmLog, frmLog);
Application.Run;
End else
begin
SetForegroundWindow(PreviousHandle);
end;
end.
我还尝试禁用我的蒙皮引擎,但这也没有帮助。
I just discovered a weird bug in my Delphi Application. When I run the application, the Taskbar shows the icon, but I have to press it in order for the form to show. By setting a breakpoint in the OnShow event, I found that the OnShow event is being fired when I click on the Icon on the Taskbar.
Also, when I use Hide;
, the form hides, but the taskbar icon does not disappear, however when I click on it, the form does not show again (which is the point, but the taskbar icon is not supposed to be there when hidden).
Here is my project file source, in case that could have something to do with it:
var
PreviousHandle : THandle;
begin
PreviousHandle := FindWindow('TfrmMain',APP_CAPTION);
if PreviousHandle = 0 then
Begin
Application.Initialize;
// So my Log and Mainform can overlap each other
Application.MainFormOnTaskbar := False;
Application.Title := 'MyApp';
Application.CreateForm(TfrmMain, frmMain);
Application.CreateForm(TfrmLog, frmLog);
Application.Run;
End else
begin
SetForegroundWindow(PreviousHandle);
end;
end.
I also tried disabling my Skinning Engine, which did not help either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WindowState 设置为 wsMinimized,编辑器以某种方式随机执行此操作。我只需将其设置为 wsNormal 就可以了。两个问题都解决了。
The WindowState was set to wsMinimized, and the editor does that randomly somehow. I just had to set it to wsNormal and it was all good. Both problems solved.
frm_login 是我的主要表单。
frm_menu 未创建。之后它将通过代码创建。
frm_login is my primary form.
frm_menu is not creating. it will creating by code after.