Wonder if there is a way to check if an application is on top of my form?
For example if you open up your form, and then open up 2 other windows(like music player and web browser), and to list these windows?
Wonder if there is a way to check if an application is on top of my form?
For example if you open up your form, and then open up 2 other windows(like music player and web browser), and to list these windows?
For example if you open up your form, and then open up 2 other windows(like music player and web browser), and to list these windows?
You could P/Invoke EnumWindows
. This will return the list of windows in z order.
As soon as your Form
is found, you'd know you no longer have to continue searching. All windows you found prior to your window Handle would be "above" your Form in the z order.
If you're only interested in windows which overlap yours, you'd have to check their position and size as well.
That standard way would be to
For each such window, determine if its bounding box intersects yours. See:
for a discussion of the algorithm. Or let the CLR do the work for you using the System.Windows.Rect.Intersect()
overloads.