简体   繁体   English

将焦点窗口移到前面

[英]Bringing focused window to the front

I have a wpf/.net 4.6.2 application. 我有一个wpf / .net 4.6.2应用程序。 What I need to do is to open browser (IE) in full screen mode and after that, in 5 seconds for ex, bring my application window to the top and make it focused, so that when I click on the browser (which is apparently behind) the application would appear covered 我需要做的是在全屏模式下打开浏览器(IE),然后在5秒钟内(例如)将我的应用程序窗口置于顶部并使其聚焦,以便在我单击浏览器时(显然是后面),该应用程序将显示为已覆盖

window.Topmost = true;
window.Topmost = false;
window.Focus();
window.Activate();

On Windows 7 it works perfectly, but on Windows 10 it appears as topmost but non-focused , and as a consequence, when I click on the browser, the application stays on top, and I have to click the application first (to give it focus) and then the browser, and only after that, browser covers the application 在Windows 7上,它可以完美运行,但是在Windows 10上,它显示为最高,但没有聚焦 ,因此,当我单击浏览器时,该应用程序位于顶部,因此我必须先单击该应用程序(将其命名)焦点),然后是浏览器,然后,浏览器才覆盖该应用程序

Unfortunately I am unable to comment yet due to my low rep; 不幸的是,由于我的代表不高,我无法发表评论。 however, I would like to suggest that you swap the focus and activate calls around. 但是,我建议您交换焦点并激活周围的呼叫。

window.Topmost = true;
window.Topmost = false;
window.Activate();
window.Focus();

Also, why are you setting the window topmost twice? 另外,为什么要将窗口设置为最高两次? This seems to be rather counter-intuitive as the final result would always be false. 这似乎是违反直觉的,因为最终结果将始终是错误的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM