Is window visible on screen...

Herman

Well-known member
Joined
Oct 18, 2011
Messages
883
Location
Montreal, QC, CA
Programming Experience
10+
So, I am facing a pretty stupid simple problem, I was wondering if anyone has a solution that wouldn't involve calculating rectangles and overlaps.

I just need to know if a particular form is visible on screen, meaning not minimized, and not hidden by another window on top of it. Pretty basic stuff, but from what I can see there is nothing in .Net or Win32 that specifically addresses that. Sure I can enumerate all forms, check which ones have an area overlapping the area of my form, then check the ZOrder property, but that seems like such a detour for a simple little property that could say true or false...

Is there another simpler way of doing this that I have overlooked?
 
Hi Herman,

I have also faced this many times and I agree there should be a simple property that you could check to see if the form is loaded. The only reasonable way I have got round this in the past is to create a public structure and set its property accordingly. i.e.

Public Structure OpenForms
Dim frmTillSessions_Loaded As Boolean
End Structure

I know it's still not great, but that's the best I ever came up with.

Cheers,

Ian
 
You misunderstand the question. What I need is to be able to determine is if the form is visible on screen, meaning not covered by another process' form and not minimized/offscreen.

In VB6 days I would have looked at the form's Z-Index, and looked at all the forms sizes and positions, determined which occupied the same area of the screen, and which had a z-index lower than my form. Now I see that MS scrapped that to prevent malicious form play, in favor of the BringToFront and SendToBack approach, which isn't bad, but they didn't even keep a read only integer property to determine at what relative position in the Z-order a form is.

The only way I have read about that seems to address this is through the GDI ClipRegion, and let's just say it's not well documented and it's not immediately evident how to achieve my goal...
 
Back
Top