如何检查窗口确实是可见的Windows窗体?窗体、确实、窗口、Windows

2023-09-03 13:06:50 作者:我是女生@

通常你用Form.Visible检查窗口是可见的。但有时在屏幕窗口低于其他窗口,以便它真的看不见的。

Normally you use Form.Visible to check if Window is visible at all. But sometimes on the screen window is below other windows so it's really invisible.

那么如何检查在C#Windows窗体,如果窗口是真的可见或不?

So how to check in c# Windows Forms if window is really visible or not?

我想做到这一点:当我点击我的键盘上的Ctrl + K和我的窗口可见我的屏幕上它什么都不做。但是,当它是它会弹出顶端其他窗口的下方(移到前面)。

I would like to accomplish this: when I click CTRL+K on my keyboard and my window is visible on my screen it does nothing. But when it's underneath other windows it pops to the top (Bring to front).

亲切的问候

推荐答案

您可以调用的 启用 的形式方法,将其带到前方,如果它是不是已经。

You can call the Activate method on the form to bring it to the front if it isn't already.

不过,请注意,如果不同的程序被激活时,它通常会简单地闪烁桌面按钮(取决于你来自哪里调用它)。这是Windows的标准的保护,防止重点窃取并你不应该去解决它。

However, note that if a different program is active, it will usually simply flash the desktop button (depending where you call it from). This is Windows' standard protection against focus-stealing and you should not try to work around it.

 
精彩推荐