Florin
Florin

Reputation: 13

Get all windows which overlap my window

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).

Upvotes: 1

Views: 959

Answers (1)

Hans Passant
Hans Passant

Reputation: 942128

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.

Upvotes: 2

Related Questions