I'm writing a program that uses SetWindowRgn
to make transparent holes in a window that belongs to another process. (This is done only when the user explicitly requests it.)
The program has to assume that the target window may already have holes which need to be preserved, so before it calls SetWindowRgn
, it calls GetWindowRgn
to get the current region, then combines the current region with the new one and calls SetWindowRgn
:
HRGN rgnOld = CreateRectRgn ( 0, 0, 0, 0 );
int regionType = GetWindowRgn ( hwnd, rgnOld );
This works fine in XP, but the call to GetWindowRgn
fails in Vista. I've tried turning off Aero and elevating my thread's privilege to SE_DEBUG_NAME
with AdjustTokenPrivileges
, but neither helps.
GetLastError() doesn't seem to return a valid value for GetWindowRgn -- it returns 0 on one machine and 5 (Access denied) on another.
Can anyone tell me what I'm doing wrong or suggest a different approach?