How to check if window is really visible in Windows Forms?

后端 未结 9 1398
小蘑菇
小蘑菇 2020-12-30 09:59

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.

So how to ch

9条回答
  •  暖寄归人
    2020-12-30 10:25

    You should be able to find out if your window is visible by overriding the OnPaint method. You'll want to pass control to the base class in order to do the actual painting, but you'll be able to detect whether a paint message is received. Update: no, this doesn't work, Sorry!

    In principle, the Activate method should bring your window to the foreground, but in practice I've always found this problematic if other processes have the input focus. If you really want someone to see a window, set the topmost bit, but expect them to be annoyed! One surefire way to get some attention for a window is to close it and reopen it, if you can get away with that.

    One way to achieve what you're looking for is to use a notify icon, this will get the user's attention in a way that is compliant with Windows UI guidelines.

提交回复
热议问题