如何在 Windows 7 的任务栏中隐藏应用程序? [英] How to hide an application from taskbar in Windows 7?

查看:36
本文介绍了如何在 Windows 7 的任务栏中隐藏应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 Windows 7 任务栏中隐藏应用程序.

I would like to hide an application from the Windows 7 taskbar.

我想在屏幕边缘做一个类似工具栏的东西,当用户点击它时它会做某些事情,但我不希望它显示在任务栏中,因为它是我想留下的东西在后台.

I want to make something like a toolbar on the edge of the screen which does certain things when the user clicks on it, but I don't want it to show in the taskbar, since its a thing that i want to stay in the background.

我尝试了以下帖子中的说明,但在我的应用程序中不起作用:

I tried the instructions in the following post, but it did not work on my application:

如何隐藏任务栏条目但保留窗体

然后我在一个新的空 VCL 表单应用程序上尝试了它,但它仍然无法正常工作.我搜索了其他解决方案,但它们的作用与链接帖子中的非常相似.

Then i tried it on a new empty VCL Forms Application and it still did not work. I searched for other solutions, but they all do very much the same like in the linked post.

有什么改变,使这在 Windows 7 中变得不可能?或者你有什么能想到,这会阻止它工作吗?

Has something changed, that makes that impossible in windows 7? Or is there anything you could think of, that could prevent it from working?

推荐答案

您可以覆盖主窗体的 CreateParam 以移除强制任务栏按钮的标志 (WS_EX_APPWINDOW)并另外使应用程序窗口拥有表单.这与 shell 为窗口放置任务栏按钮的要求相反.来自管理任务栏按钮":

You can override the main form's CreateParam to remove the flag that forces the taskbar button (WS_EX_APPWINDOW) and additionally make the form owned by the application window. That's doing the opposite of the requirement for the shell to place a taskbar button for a window. From "Managing Taskbar Buttons":

[..] 要确保窗口按钮位于任务栏上,请创建一个具有 WS_EX_APPWINDOW 扩展样式的无主窗口.[..]

[..] 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;

如果您使用此方法,请不要将应用程序"的 MainFormOnTaskbar 属性的状态从其默认的True"更改.

Don't change the state of MainFormOnTaskbar property of the 'Application' from its default 'True' if you use this method.

您也可以删除第二行 (..WndParent := ..) 并在对象检查器中将表单的 PopupMode 设置为 pmExplicit 以达到相同的效果.

You can also remove the second line (..WndParent := ..) and instead set PopupMode of the form to pmExplicit in the object inspector to same effect.

顺便说一句,这里是该解决方案同一主题的文档引用TLama 发布:

BTW, here's the documentation quote from the same topic for the solution TLama posted:

为了防止窗口按钮被放置在任务栏上,[...]作为替代方案,您可以创建一个隐藏窗口并将其隐藏window 可见窗口的所有者.

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 设计的应用程序窗口拥有.如果隐藏应用程序窗口,则满足要求.

When you set MainFormOnTaskbar to false, the main form is owned by the application window by VCL design. And if you hide the application window, the requirement is fulfilled.

这篇关于如何在 Windows 7 的任务栏中隐藏应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆