当全屏应用程序处于活动状态时防止出现 Windows 任务栏

发布于 2024-12-01 07:22:46 字数 477 浏览 1 评论 0原文

我们有一个应用程序显示一个小的“总在最上面”窗口。一般来说,这工作得很好。与其他应用程序一样,当它处于活动状态时,任务栏将其显示为已选中。

现在将幻灯片模式下的 PowerPoint 添加到组合中。我们的窗口是可见的,并且 PowerPoint 具有整个屏幕。一切都很好。直到您单击我们的窗口,Windows 7 才会显示任务栏并选择我们的应用程序。任务栏被置于 PowerPoint 全屏显示的前面,这导致用户感到困惑。特别是当他们点击任务栏上的图标时,这会导致我们的应用程序最小化。

如果我们使用 ExStyle CreateParams 设置 WS_EX_TOOLWINDOW 并确保未设置 WS_EX_APPWINDOW,那么我们不会出现在任务栏中,但任务栏仍然会被带到前面。如果有什么区别的话,使用的语言是Delphi,XE版本。

接下来的问题是,当我们的“Always on Top”应用程序处于焦点状态时,我们如何阻止 Windows 在 PowerPoint 顶部显示任务栏。

We have an application that shows a small "always on top" window. This works fine in general. Like other applications, when it is active, the TaskBar shows it as selected.

Now add PowerPoint in slideshow mode into the mix. Our window is visible, and PowerPoint has the whole screen. All fine. Until, that is, you click on our window, and Windows 7 shows the Taskbar with our app selected. The Taskbar is brought to the front of PowerPoint's full screen display, and this is causing confusion in the users. Particularly as they will then click on the icon on the taskbar which causes our app to be minimized.

If we use the ExStyle CreateParams to set WS_EX_TOOLWINDOW and ensure that WS_EX_APPWINDOW is not set, then we don't appear in the Taskbar, but the Taskbar is still brought to the front anyway. If it makes any difference, the language used is Delphi, XE version.

The question then is how we might stop Windows from showing the Taskbar over the top of PowerPoint when our Always on Top app is focussed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

香草可樂 2024-12-08 07:22:46

正如之前的评论中已经写的,这是 Windows 行为。

就我个人而言,我使用多个屏幕来避免这种行为:

  • 第一个屏幕有任务栏
  • ,我将幻灯片显示到另一个没有任务栏的屏幕(扩展桌面)。

顺便说一句,我像这样管理你所期望的......这并不是很漂亮,但我认为它有效,正如你所期望的:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, AppEvnts;

type
  TForm1 = class(TForm)
    aplctnvnts1: TApplicationEvents;
    procedure aplctnvnts1Deactivate(Sender: TObject);
    procedure aplctnvnts1Activate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    procedure SetTaskBarVisible(bVisible: Boolean);
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SetTaskBarVisible(bVisible: Boolean);
const
//  START_BUTTON_LABEL = 'Démarrer';
  START_BUTTON_LABEL = 'Start';
begin
  if bVisible then
  begin
    ShowWindow(FindWindow('Shell_TrayWnd', nil               ), SW_SHOW);
    ShowWindow(FindWindow('Button'       , START_BUTTON_LABEL), SW_SHOW);
  end
  else if FindWindow('screenClass', nil) > 0 then  // Fullscreen PowerPoint
  begin
    ShowWindow(FindWindow('Shell_TrayWnd', nil               ), SW_HIDE);
    ShowWindow(FindWindow('Button'       , START_BUTTON_LABEL), SW_HIDE);
  end;
end;

procedure TForm1.aplctnvnts1Activate(Sender: TObject);
begin
  SetTaskBarVisible(False);
end;

procedure TForm1.aplctnvnts1Deactivate(Sender: TObject);
begin
  SetTaskBarVisible(True);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  SetTaskBarVisible(True);
end;

end.

As it's already written in the previous comments, this is the Windows behavior.

Personnaly, I use several screens to avoid this behavior:

  • first screen has the taskbar
  • and I display my powerpoint to another screen without the taskbar (extended desktop).

By the way, I manage what you are expecting like this... this is not really pretty, but it works, I think, as you expect:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, AppEvnts;

type
  TForm1 = class(TForm)
    aplctnvnts1: TApplicationEvents;
    procedure aplctnvnts1Deactivate(Sender: TObject);
    procedure aplctnvnts1Activate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    procedure SetTaskBarVisible(bVisible: Boolean);
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SetTaskBarVisible(bVisible: Boolean);
const
//  START_BUTTON_LABEL = 'Démarrer';
  START_BUTTON_LABEL = 'Start';
begin
  if bVisible then
  begin
    ShowWindow(FindWindow('Shell_TrayWnd', nil               ), SW_SHOW);
    ShowWindow(FindWindow('Button'       , START_BUTTON_LABEL), SW_SHOW);
  end
  else if FindWindow('screenClass', nil) > 0 then  // Fullscreen PowerPoint
  begin
    ShowWindow(FindWindow('Shell_TrayWnd', nil               ), SW_HIDE);
    ShowWindow(FindWindow('Button'       , START_BUTTON_LABEL), SW_HIDE);
  end;
end;

procedure TForm1.aplctnvnts1Activate(Sender: TObject);
begin
  SetTaskBarVisible(False);
end;

procedure TForm1.aplctnvnts1Deactivate(Sender: TObject);
begin
  SetTaskBarVisible(True);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  SetTaskBarVisible(True);
end;

end.
笑梦风尘 2024-12-08 07:22:46

听起来您希望您的小程序显示并充当与 Powerpoint 关联的浮动工具栏,以便用户认为他们仍在使用 Powerpoint 而不是单独的应用程序?

提供这种错觉的一种方法是使用 WS_EX_NOACTIVATE< /a> 窗口上的样式:当用户单击它时,您仍然应该获得可以处理以触发功能的单击,但 Powerpoint 应该保持活动窗口。

请注意,只有当您的应用程序需要做的只是处理单击时,这才有效;如果您需要接收键盘输入,则必须激活并获得焦点,窗口将像往常一样显示任务栏。

(顺便说一句,还可以考虑使用 RegisterHotKey 实现热键,以便无法单击窗口的键盘用户仍然可以访问此功能。)

It sounds like you want your applet to appear and act as through it's a floating toolbar associated with Powerpoint, so that the user thinks they're still using Powerpoint rather than a separate application?

One way to provide this illusion is to use whe WS_EX_NOACTIVATE style on the window: when the user clicks it, you should still get clicks that you can handle to trigger your functionality, but Powerpoint should remain the active window.

Note that this only works if all your app needs to do is handle single clicks; if you need to receive keyboard input, you're going to have to become active and take focus, and windows will display the taskbar as usual.

(As an aside, also consider implementing a hotkey using RegisterHotKey so that keyboard users who can't click the window can still access whatever this functionality is.)

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