views:

43

answers:

1

I want to find all windows which entirely or partly overlap my window (are on top of it). As a special case, if I have two window handles (hWnd1 and hWnd2), I want to find if hWnd2 partly or completely overlaps hWnd1. The windows in question are desktop windows (not children/siblings in the same process).

+2  A: 

Iterate the windows that might overlap yours by repeatedly calling GetWindow(), using GW_HWNDPREV. Use GetWindowRect() to check if such a window actually overlap yours. There's no shortcut for two known windows, just check if GetWindow() returns hWnd2 while iterating.

Hans Passant
Note that GetWindow can return the original window, if it is brought to front during this iteration.
Don Reba