How to test if a control is visible on screen

G

Guest

Hallo experts

How can I test if a control is currently visible on screen and not hidden by
other windows?
 
G

Guest

How can I test if a control is currently visible on screen and not hidden by
other windows?

I'm unaware of any easy API call to do this (perhaps there is a User32
function?). In lieu of an easy solution, you could try a more brute-force
method:

1. Get an array of all open windows. (You can use the User32 EnumWindows
function and Interop to get this.)
2. Iterate through the array. Every window in the array before your window
is higher in the Z-order, i.e., can potentially cover the control in your
window.
3. Find the screen coordinates of your control. You can find the upper
left-corner with the control.PointToScreen( new Point(0,0) ) method.
4. Ensure that none of the higher-Z-order windows cover the control's
screen coordinates.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top