diff --git a/dlls/ddraw/clipper.c b/dlls/ddraw/clipper.c index 81e9e8b8f9d..89a3bf3829e 100644 --- a/dlls/ddraw/clipper.c +++ b/dlls/ddraw/clipper.c @@ -99,29 +99,38 @@ static HRESULT WINAPI ddraw_clipper_SetHWnd(IDirectDrawClipper *iface, DWORD fla static HRGN get_window_region(HWND window) { - POINT origin = {0, 0}; - RECT client_rect; + POINT origin; + HRGN rgn; + HDC dc; - if (!GetClientRect(window, &client_rect)) + if (!(dc = GetDC(window))) { - /* This can happen if the window is destroyed, for example. */ - WARN("Failed to get client rect.\n"); + WARN("Failed to get dc.\n"); return NULL; } - if (!ClientToScreen(window, &origin)) + if (!(rgn = CreateRectRgn(0, 0, 0, 0))) { - ERR("Failed to translate origin.\n"); + ERR("Failed to create region.\n"); + ReleaseDC(window, dc); return NULL; } - if (!OffsetRect(&client_rect, origin.x, origin.y)) + if (GetRandomRgn(dc, rgn, SYSRGN) != 1) { - ERR("Failed to translate client rect.\n"); + ERR("Failed to get window region.\n"); + DeleteObject(rgn); + ReleaseDC(window, dc); return NULL; } - return CreateRectRgnIndirect(&client_rect); + if (GetVersion() & 0x80000000) + { + GetDCOrgEx(dc, &origin); + OffsetRgn(rgn, origin.x, origin.y); + } + + return rgn; } /*****************************************************************************