简体   繁体   中英

Bringing focused window to the front

I have a wpf/.net 4.6.2 application. 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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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