如何在全屏应用程序中置顶但不置顶

发布于 2025-01-02 11:57:07 字数 883 浏览 0 评论 0原文

因此,我尝试花一天中的大部分时间来寻找一个简单问题的答案。我希望我的 C# 应用程序在计时器上弹出另一个 winform,然后在延迟后将其关闭。很简单,完成了。现在我的问题是我希望它实际上位于其他应用程序之上,除非它们是全屏的。我指的是真正的全屏应用程序,例如游戏。我不想干扰这样的申请,因为它应该优先于我的申请。

问题是我在弹出窗体上使用“OnTop”属性,虽然它对于任何其他应用程序都完美工作,但我在玩全屏游戏和窗体时一直在测试它,当它“Show()”时,获取全屏应用程序并将其置于窗口模式。

这是“OnTop”属性对全屏应用程序的预期效果吗?如果是这样,有没有一种方法可以让我的表单弹出在正常窗口的顶部,而不干扰全屏应用程序?

任何链接,例如,大方向上的一击都是很棒的。在搜索涉及全屏的 winform 时,我遇到的唯一问题是人们试图将他们的应用程序设置为全屏,或者让他们的应用程序将焦点从另一个应用程序上移开。

提前致谢。

(我没有发布任何代码,因为它只是一个简单的winform,即在带有“onTop”属性集的计时器上的“formX:Show()”)


(编辑)所以感谢awilson53让我走上正确的轨道我找到了一种方法(尽管有些挑剔)来确定应用程序是否全屏。看起来有点简单,而且“好吧”,毕竟已经说了又做了。

95% 的功劳归功于文章的作者:http://www.richard-banks.org/2007/09/how-to-detect-if-another-application-is.html

~5% 交给 awilson53 来找到我在正确的轨道上。 :)

So I have tried searching for the better part of a day for the answer to a simple question. I want my C# application to popup another winform on a timer and then close it after a delay. Simple enough, done and done. Now my issue is that I want it to actually be on top of other applications UNLESS they are full screen. By that I mean a true full screen application such as a game. I do not want to interfere with such an application since it should take priority over my application.

The issue is that I am using the 'OnTop' property on the popup form and, while it works perfectly for any other applications I have been testing it while playing a full screen game and the form, when it "Show()"s, takes the full screen application and drops it into windowed mode.

Is this the intended effect of the 'OnTop' property with full screen applications? If so is there a way that I can have my form popup on top of normal windowed windows and not interfere with full screen applications?

Any links, example, a kick in the general direction is great. The only hits that I come up with when searching for winforms involving full screen is people trying to get their application into full screen or having their application take focus away from another application.

Thanks on advance.

(I didn't post any code due to it just being a simple winform that is "formX:Show()" on a timer with the "onTop" property set)


(EDIT) So thanks to awilson53 for putting me on the right track I was able to find a method (albeit somewhat picky) to determine if an application is full screen. Seems kinda simple, and an "well duh", answer after all is said and done.

95% of the credit goes to the author of the article: http://www.richard-banks.org/2007/09/how-to-detect-if-another-application-is.html

~5% goes to awilson53 for getting me on the right track. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情释 2025-01-09 11:57:07

查看这个 EnumWindows 函数的包装器。这将允许您枚举所有打开的窗口并确定它们的窗口状态。您需要检查 EnumWindowItem.Maximized 属性,如果为 true,则将 OnTop 属性设置为 false。如果没有 EnumWindowItem 返回 Maximized,您可以将 OnTop 设置为 true。

Check out this wrapper for the EnumWindows function. This will allow you to enumerate all open windows and determine their window state. You will want to check the EnumWindowItem.Maximized property, and if it is true set your OnTop property to false. If none of the EnumWindowItem's return Maximised you can set OnTop to true.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文