问题标签 [always-on-top]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
3131 浏览

c# - 如何制作一个点击和透视的“始终在顶部”窗口

我想显示一个带有一些信息的半透明始终在顶部的窗口,但我不希望这个窗口接受输入或接收焦点。所有鼠标单击都应转到底层窗口。

我记得几年前在一个外壳替换应用程序中看到过这个,但我不记得女巫了。

任何想法如何用delphi或c#实现这种效果?

更新:

我不能完全得到建议的解决方案来使用 delphi。为 NCHITTEST 消息返回 HTTRANSPARENT 将阻止所有鼠标消息到达表单,但它希望将其传递到 z 顺序中的下一个窗口。这种方法是跨进程工作,还是只对特定窗口的子元素起作用?

但是,如果我设置了 ExStyle 标志 WS_EX_TRANSPARENT,所有的鼠标点击都将进入下一个窗口,但我根本不会收到 NCHITTEST 消息,并且无法控制窗口应该点击的位置。 ..

0 投票
1 回答
504 浏览

mfc - 用户界面:切换 MDI 框架顶部状态的最佳方式?

我维护一个使用 Frame Windows 作为文档视图的 MFC (VC6) MDI 应用程序。一次只有一个文档,但有多个 MDI 框架,每个框架都有不同的文档数据视图。

最近出现了一个请求,即能够将这些框架窗口中的一个保持在其他框架窗口之上,同时能够与背景窗口进行交互。

  • 一个想法是在框架的标题栏中添加一个“固定按钮”。在我的研究中,我发现每个实现都使用位图而不是例如 CButton 对象。一旦使用默认灰色以外的窗口颜色,更不用说 UI 主题,这就会开始变得难看。

  • 框架窗口菜单中的一个选项(左键单击标题栏中的窗口图标时出现的东西)是可能的,但我正在寻找对用户更明显的东西。

设置此框架窗口的顶部状态还有哪些其他可能性?

更新

我决定采用 Uli 建议的解决方案,因为该解决方案适用于 XP 主题。不幸的是,这直接引出了我的下一个问题:我怎样才能真正让框架窗口保持在顶部?

0 投票
6 回答
46385 浏览

css -
PDF 上的图层

所以,我面临的问题是这样的:我有一个图层,它将被放置在页面上的 pdf 之上。PDF 要么用于嵌入,要么用于 iframe 以包含它。但是,CSS 样式不适用于 PDF(因为它是一个插件?)。因此,即使我将 z-index:1000 放在 ,该层仍然位于 PDF 后面。知道如何解决吗?

这是代码:

0 投票
3 回答
15739 浏览

c++ - 始终在前的对话框

有没有办法在 C++ MFC 中创建一个始终位于应用程序中其他窗口之上的无模式对话框?我想的有点像 Visual Studio 2005 中的“查找”对话框——它位于顶部,但您仍然可以编辑底层文本。

(如果有什么不同,那不是 MDI;它是一个基于对话框的应用程序)

0 投票
2 回答
3164 浏览

mfc - 如何使 MDI 子窗口保持在其兄弟窗口之上?

这个问题与我之前的问题有关。

我有一个 MFC (VC6) MDI 应用程序,它有几个 MDI 子窗口充当一个文档的不同视图。

是否可以将其中一个框架设置在其他框架之上?
我试过打电话

来自 CMDIChildWnd 但似乎都不起作用。

0 投票
3 回答
693 浏览

c# - Prevent Process 'A' from spawning Process 'B' which then shows up on top of what should be the "TopMost" Process 'C'

I have a windows form application which needs to be the TopMost. I've set my form to be the TopMost and my application works as I'd like it to except for in one case.

There is a 3rd party application (referred to as player.exe) that displays SWF movie files on a portion of the screen that popup on top of my application.

Using Process Monitor I determined that player.exe application calls
flash.exe <PositionX> <PositionY> <Width> <Height> <MovieFile>
in my case:
flash.exe 901 96 379 261 somemovie.swf

Since flash.exe is being spawned in a new process after my form has been set to the TopMost it is appearing on top of my application.

First thing I did was make my application minimize the player.exe main application window hoping that this would prevent the Flash from appearing also. But, unfortunately it doesn't... even with the window minimized whenever the flash movie starts it shows up at the pixel location (901,96). I then tried creating a timer to keep setting the form.TopMost property to true every 10ms. This sort of works but you still see a very quick blip of the swf file.

Is there some type of Windows API call which can be used to temporarily prevent player.exe from spawning child processes which are visible? I admit it sounds a little far fetched. But, curious if anyone else has had a similar problem.


Addendum:

This addendum is to provide a reply to some of the suggestions layed out in Mathew's post below.

For the emergency situation described in the comments, I would look at possible solutions along these lines:

1) How does the third party application normally get started and stopped? Am I permitted to close it the same way? If it is a service, the Service Control Manager can stop it. If it is a regular application, sending an escape keystroke (with SendInput() perhaps) or WM_CLOSE message to its main window may work.

Easiest way to close the app is to CTRL-ALT-DEL, then kill process. -OR- The proper way is to Hold ESC while clicking the left mouse button... then input your username and password, navigate some menu's to stop the player.

There is no PAUSE command... believe it or not.

I don't think using WM_CLOSE will help since minimizing the application doesn't. Would that kill the process also? If not, how do you reopen it.

2) If I can't close it nicely, am I permitted to kill it? If so, TerminateProcess() should work.

I can't kill the process for two reasons. 1) Upon relaunch you need to supply username/password credentials... There may be a way to get around this since it doesn't prompt when the machine is rebooted but... 2) Whenever I kill the process in task manager it doesn't die gracefully and asks if you want to send an error report.

3) If I absolutely have to leave the other process running, I would try to see if I can programmatically invoke fast user switching to take me to a different session (in which there will be no competing topmost windows). I don't know where in the API to start with this one. (Peter Ruderman suggests SwitchDesktop() for this purpose in his answer.)

I got really excited by this idea... I found this article on CodeProject which provides a lot of the API Wrapper methods. I stopped implementing it because I think that in order for desktop's to work you must have explorer.exe running (which I do not).

EDIT2: On second thought... maybe explorer.exe isn't needed. I'll give it a try and report back.

Edit3: Was unable to get the code in that article working. Will have to put this on hold for a moment.


Answer Summary

As one might have expected, there is no simple answer to this problem. The best solution would be to problematically switch to a different desktop when you need to guarantee nothing will appear over it. I was unable to find a simple C# implementation of desktop switching that worked and I had a looming doubt that I would just be opening a whole new set of worms once it was implemented. Therefore, I decided not to implement the desktop switching. I did find a C++ Implementation that works well. Please post working C# virtual desktop implementations for others.

0 投票
2 回答
1100 浏览

java - 尝试在截屏之前将摆动框架置于前面但得到伪影

我的应用程序的一部分截取了某个窗口的屏幕截图,但在我这样做之前,我想把窗口放在前面。这在我的 Mac 机器上运行良好,但是当我在 Windows XP 上并行测试它时,屏幕截图总是在重叠窗口所在的位置出现灰色区域。似乎总是在我想要在顶部的窗口被转移到顶部时截取屏幕截图。我试过同时使用:

有人对此问题有合理的解决方案吗?

0 投票
1 回答
190 浏览

windows - Flex Window 始终在顶部

alwaysOnTop="true"mx:WindowedApplication标签中设置。这在 OSX 中不起作用,但在 Windows 中起作用。

我怎样才能为 OSX 解决这个问题?

0 投票
1 回答
933 浏览

swing - 保持在主应用程序窗口顶部的最小化 JFrame

我的应用程序会弹出一个对话框。用户通常希望在此对话框和应用程序窗口之间来回切换一段时间。我希望这个对话框保持在顶部,这样它就不会隐藏在主应用程序窗口后面。但同时我希望对话框有一个最小化按钮,以便在一段时间内不需要它时可以让开。

这是我尝试过的:

  • 使用无模式的 JDialog - 对话框很好地保持在前面,但它没有最小化按钮,也没有自己的任务栏按钮

  • 使用 JFrame - 对话框现在有一个最小化按钮和它自己的任务栏按钮,但是当主窗口获得焦点时,对话框隐藏在它后面。

  • 使用 JFrame 并在对话框中添加 WindowListener.windowDeactivated() { this.toFront() }。这样做的问题是 toFront() 也设置了焦点,所以你会得到一个奇怪的焦点闪烁效果。

  • 使用带有 setAlwaysOnTop 的 JFrame - 这是最接近的解决方案,但现在窗口将位于所有其他应用程序之上,而不仅仅是我的应用程序。

如果 toFront 只是在不改变焦点的情况下将 JFrame 带到前面会很容易,但不幸的是,情况并非如此。是否有另一种方法来更改 JFrame Z 顺序?

编辑:我突然想到,如果有一种简单的方法可以“汇总”JDialog,即最小化它而不是任务栏,那也可以解决我的问题。

0 投票
3 回答
11588 浏览

python - 如何使 python 窗口以“始终在顶部”运行?

我在 python 中运行一个小程序,它启动一个需要保持在所有其他窗口之上的小窗口。我相信这是特定于操作系统的,它是如何在带有 GNOME 的 GNU-Linux 中完成的?

[更新 - Windows 解决方案]

可爱,我想我成功了。我在 Vista 64 位的 Eclipse 中使用 Python 2.5.4 和 Pygame 1.9.1。因此,这适用于 Windows 系统。该SetWindowPos功能记录在此处。我将在我的解释中提到这一点。

进口:

然后我在 user32 中设置了一个调用“SetWindowPos”的变量:

现在,假设我刚刚做了一个窗口:

下一行是关键。这会将窗口设置在其他窗口的顶部。

基本上,您向hWnd(Window Handle) 提供从调用返回的窗口 ID display.get_wm_info()。现在该函数可以编辑您刚刚初始化的窗口。

-1是我们的hWndInsertAfter

MSDN 网站说:

可以通过将 hWndInsertAfter 参数设置为 HWND_TOPMOST 并确保未设置 SWP_NOZORDER 标志,或者通过设置窗口在 Z 顺序中的位置,使其位于任何现有的最顶层窗口之上,可以使窗口成为最顶层窗口。当非最顶层窗口成为最顶层时,其拥有的窗口也被置为最顶层。然而,它的所有者并没有改变。

因此,-1确保窗口高于任何其他现有的最顶层窗口,但这可能不适用于所有情况。也许-2胜过-1?它目前对我有用。:)

xy指定正在设置的窗口的新坐标。SetWindowPos我希望窗口在调用函数时保持在当前位置。唉,我找不到一种方法可以轻松地将当前窗口 (x,y) 位置传递给函数。我能够找到解决方法,但假设我不应该在这个问题中引入新主题。

应该指定窗口的0, 0,新宽度和高度,以像素为单位。好吧,该功能已经在您的pygame.display.set_mode()函数中,所以我将它们保留为 0。0x0001忽略这些参数。

0x0001对应于 SWP_NOSIZE 并且是我唯一的 uFlag。所有可用 uFlags 的列表都在提供的文档页面上。它们的一些十六进制表示如下:

  • SWP_NOSIZE = 0x0001
  • SWP_NOMOVE = 0x0002
  • SWP_NOZORDER = 0x0004
  • SWP_NOREDRAW = 0x0008
  • SWP_NOACTIVATE = 0x0010
  • SWP_FRAMECHANGED = 0x0020
  • SWP_SHOWWINDOW = 0x0040
  • SWP_HIDEWINDOW = 0x0080
  • SWP_NOCOPYBITS = 0x0100
  • SWP_NOOWNERZORDER = 0x0200
  • SWP_NOSENDCHANGING = 0x0400

应该是这样!希望对你有帮助!

感谢 John Popplewell 在 john@johnnypops.demon.co.uk 的帮助。