Is HWND visible?
Asked Answered
J

3

6

Those darned users and their minimized windows.

In C#, if I have a window's HWND, is there a way to tell if it is visible on the desktop?

Jorie answered 15/11, 2009 at 20:57 Comment(2)
We are all users, too, and who to you program for anyway if not for the users? By the time of this writing I have 5 minimized windowsGonyea
The echos of sarcasm from five years past.Jorie
S
5

The GetWindowPlacement function returns a WINDOWPLACEMENT structure which has a field showCmd:

Specifies the current show state of the window.

The details of this read as though you would be setting the window state, but I suspect that this is because they've been copied from somewhere else and not updated.

Sour answered 15/11, 2009 at 21:3 Comment(1)
Phew thanks, spent at least 10 minutes of boring googling to find out how the heck one is supposed to check window visibility via WinAPI... The name is a little obscure and of course the documentation for how to hide a window doesn't link to it...Eagre
D
3

There's the Visible property, but that checks the visible flag, it doesn't tell you whether the window is being covered by another window, or off the screen, etc.. That's a lot more tricky. Raymond Chen has some tips, though:

Doyon answered 15/11, 2009 at 21:3 Comment(0)
P
1
bool isHwndVisible = Control.FromHandle(handle).Visible
Podesta answered 15/11, 2009 at 21:1 Comment(1)
That only works for (Managed) Controls in the current Application. I think the OP is referring to another application.Stichter

© 2022 - 2024 — McMap. All rights reserved.