Click here to Skip to main content
15,898,747 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,

I am writing a program in c++ to check weather a window (open by a user ex: notepad) is visible or not using "iswindowvisible(HWND hWnd)" function.
But it always returns a zero.

Need your help to resolve this problem.

Thank you
Suryakant tyagi
Posted
Comments
jeron1 2-Nov-15 16:17pm    
Maybe post some code that's relevant to your problem.
Suryakant Turing 3-Nov-15 2:17am    
I got your point but I still getting zero output while using FindWindow() and then IsWindowvisible().

I also have process Id and execution application name if it can help in another way.

Thank you

1 solution

Check these:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633530(v=vs.85).aspx[^]

http://stackoverflow.com/questions/1061246/how-can-i-check-if-a-window-has-ws-visible-to-set-or-if-is-visible[^]

This quote from first link is crucial:
"If the specified window, its parent window, its parent's parent window, and so forth, have the WS_VISIBLE style, the return value is nonzero. Otherwise, the return value is zero."

From the second link a solution:
"One nuance to be aware of. IsWindowVisible will return the true visibility state of the window, but that includes the visibility of all parent windows as well.

If you need to check the WS_VISIBLE flag for a specific window you can do GetWindowLong(hWnd, GWL_STYLE) and test for WS_VISIBLE."
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900