最顶层窗口的后面去非最顶层全屏窗口有时 [英] TopMost window going behind non-TopMost fullscreen window sometimes

查看:166
本文介绍了最顶层窗口的后面去非最顶层全屏窗口有时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制工具栏应用程序,需要浮在一切双显示器系统的主要画面之上。它自己定位在主屏幕的顶部,并设置最顶层=真

I have a "control toolbar" app that needs to float on top of everything else on the primary screen of a dual monitor system. It positions itself at the top of the primary screen and sets TopMost=true.

此控制工具栏,可以用来发射其中两个全屏运行,但其他进程不在最上方,一个双显示器系统上的每个显示器上。这些窗口设置为全屏运行通过设置边框无,设置窗口的范围,从而精确匹配到屏幕尺寸。全屏窗口没有问题覆盖任务栏,我可以集中精力和全屏窗口在主显示器上整天互动,并在工具栏停留在顶端。

This control toolbar can be used to launch two other processes which run fullscreen but NOT TopMost, one on each monitor on the dual monitor system. These windows are setup to run fullscreen by setting BorderStyle to None and setting the bounds of the window to fit exactly into the screen dimensions. The fullscreen windows have no problem covering the taskbar, and I can focus and interact with the fullscreen window on the primary monitor all day and the toolbar stays on top.

所有不桃色的软件王国但是 - 某些行动令下,非最顶层全屏窗口最上面的工具栏弹出。其中一个行动就是在辅助监视器上的全屏应用程序提供焦点,然后让焦点回到全屏应用程序,在主显示器上。这是为了重现,因为它发生的每一次我按照这个序列时间的最简单的情况。我有一个很难复制其他场景可靠,但如果我打的Windows键拉涨开始菜单,开始浏览Internet Explorer中的有时的,当我浏览完毕并关闭IE浏览器,让焦点回到到主监视器全屏应用程序,它会弹出在最顶层的窗口。

All is not peachy in the kingdom of software however - certain actions make the TopMost toolbar pop under the non-TopMost fullscreen windows. One of those actions is giving focus to the fullscreen app on the secondary monitor, then giving focus back to the fullscreen app on the primary monitor. This is the easiest situation to reproduce as it happens every time I follow this sequence. I have a hard time reproducing other scenarios reliably, but if I hit the windows key to pull up the start menu and start browsing in Internet Explorer, sometimes when I am done browsing and close IE and give focus back to the primary monitor fullscreen app it pops over the TopMost window.

不知道如何继续上面的顶层窗口,而不是允许其在非最顶层全屏窗口弹出?我不介意做这样的事情轮询WindowFromPoint每秒一次,看看如果工具栏仍然在上面,如果不是那么流行回来了不知怎么的,但我不想把注意力从全屏应用程序,如果那是什么用户使用,所以激活()是不是一个特别好的解决办法。

Any idea how to keep the TopMost window on top, and not allow it to pop under a non-TopMost fullscreen window? I wouldn't mind doing something like polling WindowFromPoint once a second to see if the toolbar is still on top and if not then pop it back over somehow, but I don't want to take focus away from the fullscreen app if that's what the user is using, so Activate() isn't a particularly good solution.

我不认为这真的很重要,但工具栏是一个WPF窗口和全屏应用程序是的WinForms。

I don't think this really matters, but the toolbar is a WPF window and the fullscreen apps are WinForms.

更新:

对此进行测试的最简单方法是preSS F11进入全屏模式在两个浏览器窗口的每个显示器上模拟了全屏幕应用程序,然后有一个最顶层的窗口浮动的任何地方。两个全屏窗口之间点击,你会看到在他们的最顶层窗口弹出。我打开IE浏览器一台显示器和Chrome在另一个上,因为IE不能让我做两全屏窗口。

The easiest way to test this is to press F11 to go fullscreen in two browser windows on each monitor to simulate the full screen apps and then have a TopMost window floating anywhere. Click between the two fullscreen windows and you will see the TopMost window pop under them. I opened IE on one monitor and Chrome on another since IE doesn't let me do two fullscreen windows.

我实现了激活()黑客现在,但它是一个比较难看的解决方案,因为它会激活工具栏应用程序,它unfocuses全屏应用程序,从而使任务栏弹出在全屏应用程序。类哈克时,所有你想要做的是开关,全屏应用程序具有焦点。

I implemented the Activate() hack for now, but it's a rather ugly solution because it activates the toolbar app which unfocuses the fullscreen app, which in turn makes the taskbar pop over the fullscreen app. Kind of hacky when all you want to do is switch which fullscreen app has focus.

推荐答案

好了,这是我落得这样做......我想出了一个更多的想法之前,我打算放弃了,这工作得很好。在工具栏上的窗口我有一个计时器,轮询最上面的窗口在工具栏区域以每秒一次的,像这样的:

Okay, here is what I ended up doing...I came up with one more idea before I was going to give up and this works well. In the toolbar window I have a timer that polls the top most window over the toolbar area once a second, like this:

var topMostHandle = WindowFromPoint((int)(Left + ActualWidth / 2), (int)ActualHeight / 2);

if (topMostHandle != new WindowInteropHelper(this).Handle)
{
    Topmost = false;
    Topmost = true;
}

所以,我基本上只是把工具栏和测试的中间点,看是否在工具栏上的顶部。如果没有,我最顶层设置为false,回到真实的,这似乎使其重回巅峰的没有的激活。它消失了第二闪光灯是有点恼人,但我不希望这经常发生。

So I basically just take a point in the middle of the toolbar and test to see if the toolbar is on top. If not, I set TopMost to false and back to true, which seems to bring it back on top without activating it. The flash where it disappears for a second is slightly annoying but I don't expect this to happen often.

感谢汉斯帕桑特寻找的的Win7 SP1的修补程序,以解决该问题:的http://支持。 microsoft.com/kb/2733420

Credit to Hans Passant for finding a hotfix for Win7 SP1 that addresses the problem: http://support.microsoft.com/kb/2733420

我一直在我的code黑客攻击的情况下客户端不能/不会运行修补程序作为一种解决方法。

I kept my hack in the code in case clients can't/aren't running the hotfix as a workaround.

这篇关于最顶层窗口的后面去非最顶层全屏窗口有时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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