开发者

Preventing the Windows task bar from appearing when a full screen app active

开发者 https://www.devze.com 2023-03-31 06:07 出处:网络
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.

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 ove开发者_Python百科r the top of PowerPoint when our Always on Top app is focussed.


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.


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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消