Search code examples
c++winapivideo-capture

Win32/Gdigrab - How to set another process window as borderless?


I am currently using GDIGRAB to capture a window. The problem is, because of the border, the mouse cursor has an offset on its position.

The idea is to put a window as borderless so the offset won't appear anymore. Given the handle of the aimed process, how can I change a window from windowed to borderless ?


Solution

  • Don't tinker with another process' windows. Instead, get the border offset.

    HWND window = ...;
    RECT wndRect, clientRect;
    GetWindowRect(window,&wndRect);
    GetClientRect(window,&clientRect);
    POINT borderOffset={clientRect.left,clientRect.top};
    ClientToScreen(window,&borderOffset);
    borderOffset.x-=wndRect.left;
    borderOffset.y-=wndRect.top;
    // borderOffset now contains the x and y offsets for the window