Sunday, April 3, 2011

How do I detect which Window is obscuring another?

If I have the handles to two windows, how can I tell whether one is obscuring the other? Obviously I can easily do a collision test, but how do I test / find out their "z order"? The windows are from totally different apps.

I am probably missing something fairly obvious..

From stackoverflow
  • WindowFromPoint, (use a point bounded by one window, and see if you get back that window's handle, or the other one).

    For partial obscuration, you can use the clipping system. I discuss this in more detail on my website here

  • This page talks about the Z ordering of windows. It doesn't mention a function to get the Z order directly, but it does point at GetNextWindow(), which given one window can return the next (or previous, don't let the name fool you) in the Z order. Using that, you should be able to figure it out.

0 comments:

Post a Comment