简体   繁体   English

有没有办法保证Internet Explorer始终是最顶层的窗口?

[英]Is there a way to guarantee that internet explorer will alway be the topmost window?

I'm trying to force an internet explorer window to be TOPMOST. 我正试图强迫一个Internet Explorer窗口成为TOPMOST。 No other windows should show on top of the internet explorer window. Internet Explorer窗口顶部不应显示其他窗口。 I have to use internet explorer. 我必须使用Internet Explorer。 I'm also running this in Windows 7. Apparently that makes a difference but all the information I found on that is rather vague and basically consists of people shouting "why isn't this easier!". 我也在Windows 7中运行它。显然这有所不同,但我发现的所有信息都相当含糊,基本上是由人们喊“为什么这不容易!”。 This is my code: 这是我的代码:

HWND ieWin = FindWindow(TEXT("IEFrame"), 0);
SetFocus(ieWin);
SetWindowPos(ieWin, HWND_TOPMOST, 0, 0, 100, 100, SWP_SHOWWINDOW );
UpdateWindow(GetParent(ieWin));

This is running in a loop so I can force the window to have these settings continuously but it's not helping. 这是在一个循环中运行,所以我可以强制窗口持续进行这些设置,但它没有帮助。 Sometimes the above code works and sometimes it doesn't. 有时上面的代码有效,有时却没有。

After much discussion I did wind up forcing the window to stay on top using a loop. 经过多次讨论,我确实结束了使用循环强制窗口保持在顶部。 If anyone else really needs to do this in the future they really need to make sure they are following the steps below. 如果将来其他人真的需要这样做,他们确实需要确保他们遵循以下步骤。

1) Ensure that they will have absolute control over the windows that their user can open. 1)确保他们可以完全控制用户可以打开的窗口。 In my case The user will only be able to open my program and internet explorer. 在我的情况下,用户只能打开我的程序和Internet Explorer。

2) The first time you set the IE window to show set it to the foreground. 2)第一次将IE窗口设置为show时将其设置为前景。

3) While looping to set the window to TOP_MOST do NOT set the focus to the IE window. 3)循环将窗口设置为TOP_MOST时,不要将焦点设置为IE窗口。

4) Make sure you have SWP_SHOWWINDOW, SWP_NOSIZE, and SWP_NOMOVE. 4)确保你有SWP_SHOWWINDOW,SWP_NOSIZE和SWP_NOMOVE。 Otherwise that loop will change your window's size and place at every iteration. 否则该循环将在每次迭代时改变窗口的大小和位置。

And if you can avoid it at all possible, don't ever do this at all :P 如果你可以尽可能地避免它,那就不要这样做了:P

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

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