Transparent window

This works:



    const auto hwnd = GetActiveWindow();

    if (hwnd)
    {
        SetWindowLongPtr(hwnd, GWL_STYLE, WS_VISIBLE);
        SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT);

        RECT rect;
        GetWindowRect(hwnd, &rect);
        SetWindowPos(hwnd, HWND_TOPMOST, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_SHOWWINDOW);

        const MARGINS margins{ -1 };
        DwmExtendFrameIntoClientArea(hwnd, &margins);
    }
    

Remove WS_EX_LAYERED if you don’t want click-through

1 Like