本文介绍了强制应用程序在OnCreate过程中显示TaskBar图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用delphi XE2。在我的Main form OnCreate过程中,我运行一些重要的元素,例如登录过程等。我的问题是,当我显示登录表单(由OnCreate过程调用)时,我的应用程序在TaskBar上不可见-当主表单变为可见时,它就变为可见。问题是,当用户用另一个应用程序覆盖了我的登录表单,而在taskBar上没有图标时,他可能不知道我的应用程序已在运行,然后尝试重新启动它。他必须使用ctrl + tab来获取我的应用程序登录表单。

I use delphi XE2. During my Main form OnCreate procedure I run some important elements, like login procedure and so on. My problem is, that when I show login form (invoked by OnCreate procedure), my application is not visible on TaskBar - it became visible when main form became visible. The problem is, that when user covered my login form by another application, without icon on taskBar he might not know that my application already runs and try to start it again. He must use ctrl+tab to get my application login form.

现在的问题...当不使用OnCreate过程时,如何强制应用程序/ OS在任务栏上显示应用程序图标

Now question... How to force application / OS to show application icon on Taskbar when OnCreate procedure is not finished?

致谢
Mario

regardsMario

推荐答案

覆盖登录表单的 CreateParams 以包括前样式。

You can override the login form's CreateParams to include WS_EX_APPWINDOW ex-style.

type
  TLoginForm = class(TForm)
    ..

  protected
    procedure CreateParams(var Params: TCreateParams); override;
    ...

  end;

procedure TLoginForm.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
end;

这篇关于强制应用程序在OnCreate过程中显示TaskBar图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 13:37