我想从 Windows 7 任务栏隐藏应用程序。
我想在屏幕边缘制作一个类似工具栏的东西,当用户单击它时它会执行某些操作,但我不希望它显示在任务栏中,因为它是我想保留的东西在后台。
我尝试了以下帖子中的说明,但它对我的应用程序不起作用:
How to hide a taskbar entry but keep the window form
然后我在一个新的空 VCL 表单应用程序上尝试了它,但它仍然不起作用。我搜索了其他解决方案,但它们的作用都与链接的帖子中的非常相似。
是否发生了某些变化,导致 Windows 7 中无法实现此操作?或者有什么你 你能想到,这会阻止它工作吗?
最佳答案
您可以覆盖主表单的 CreateParam
以删除强制任务栏按钮 (WS_EX_APPWINDOW
) 的标志,并另外使表单拥有应用程序窗口。这与 shell 为窗口放置任务栏按钮的要求相反。来自“Managing Taskbar Buttons”:
[..] To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style. [..]
示例:
type
TForm1 = class(TForm)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.ExStyle := Params.ExStyle and not WS_EX_APPWINDOW;
Params.WndParent := Application.Handle;
end;
如果使用此方法,请勿更改“Application”的 MainFormOnTaskbar
属性的默认状态“True”。
您还可以删除第二行 (..WndParent := ..) 并在对象检查器中将表单的 PopupMode
设置为 pmExplicit
以达到相同的效果。
顺便说一句,这是来自同一主题的解决方案的文档引用 TLama posted :
To prevent the window button from being placed on the taskbar, [...] As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.
当您将MainFormOnTaskbar
设置为false时,根据VCL设计,主窗体由应用程序窗口拥有。如果隐藏应用程序窗口,则满足要求。
关于delphi - 如何在 Windows 7 任务栏中隐藏应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14811935/