FormCreate 和 Hide 之后不会触发 FormShow 事件;不隐藏任务栏上的图标

发布于 2024-11-25 10:10:21 字数 780 浏览 3 评论 0原文

我刚刚在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请恋爱 2024-12-02 10:10:21

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.

九八野马 2024-12-02 10:10:21
frm_login.hide;
Application.MainFormOnTaskbar := false;
ShowWindow(Application.Handle, SW_SHOW);

frm_login 是我的主要表单。
frm_menu 未创建。之后它将通过代码创建。

frm_login.hide;
Application.MainFormOnTaskbar := false;
ShowWindow(Application.Handle, SW_SHOW);

frm_login is my primary form.
frm_menu is not creating. it will creating by code after.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文