Determine if Form visible (to the eye)

  • Thread starter Thread starter vooose
  • Start date Start date
V

vooose

How would you determine if a window(Form) is visible. By visible I mean
that you can currently see it, as apposed to Form.Visible. (which
returns True when the window sits behind other windows)

Using Form.Focused is no good because the form is still visible even
when its not focused.
 
vooose said:
How would you determine if a window(Form) is visible. By visible I mean
that you can currently see it, as apposed to Form.Visible. (which
returns True when the window sits behind other windows)

Using Form.Focused is no good because the form is still visible even
when its not focused.

What happens if 90% of the form is hidden by another, in your definition of
visible does that count as visible or not?

Michael
 
Hi Michael. If any is visible then the IsReallyVisible func. should
return true.

The reason I need this is so: When the user clicks and holds the mouse
down, then releases I want to determine if they released OVER a certain
Form. It is returning true even when the form isnt "visible" - ie
another window sits above it

Regards
 
Michael said:
What happens if 90% of the form is hidden by another, in your definition of
visible does that count as visible or not?
I would think 90% would be a no-brainer - clearly it's still visible.
More interesting would be the case where only 1 pixel of the form was
visible, which is possible even if it were covered only by 2
overlapping rectangular windows that intersected one pixel in from the
corner. If the OP really just wanted to know "is any pixel of my form
not covered by another window, and within the desktop bounds", it
*might* be possible by checking the windows clipping region (although
I'm not sure what API's would tell you this for the NC area), but
certainly could be calculated by examining every other overlapping
window on the desktop. Why you'd need to know this I can't imagine!
 
vooose said:
Hi Michael. If any is visible then the IsReallyVisible func. should
return true.

The reason I need this is so: When the user clicks and holds the mouse
down, then releases I want to determine if they released OVER a certain
Form. It is returning true even when the form isnt "visible" - ie
another window sits above it
But that's an easier problem - now you just want to know which window
is at the top of the Z order given a certain x,y location. The Windows
API has a function "WindowFromPoint" designed to do this, although it
isn't terribly clear from the doco that it only selects visible windows
at the top of the z order (I'm 99% certain it will always give the
topmost window, but it appears to also work for hidden windows, so
you'd have to test whether the window was actually visible).
 
But that's an easier problem - now you just want to know which window
is at the top of the Z order given a certain x,y location. The Windows
API has a function "WindowFromPoint" designed to do this, although it
isn't terribly clear from the doco that it only selects visible windows
at the top of the z order (I'm 99% certain it will always give the
topmost window, but it appears to also work for hidden windows, so
you'd have to test whether the window was actually visible).

Actually scrap that - it definitely ignores hidden (and for that matter
disabled) windows, but it *might* return a window that is a child
window to the window you care about (e.g., a control on your form), so
you may need to handle this explicitly. Otherwise, comparing the HWND
returned from WindowFromPoint with your form's Handle property should
do the trick.
 
Yea sorry for this problem it is basically determining which form is on
top of the Z-order. I will check out WindowFromPoint and see how that
goes. I asked the original problem because I thought it was interesting
(and may be required later) - my bosses are always asking
'if the user aren't looking at a window then send them a notifier'

Well now the definition of 'aren't looking' comes into play. If the
window is minimised then its easy...if its got 50% showing you could
assume they r looking at it. It would be nice if there was a function
that returned the % of "visible" window or whether it was visible at all

Regards
 

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

Back
Top