I am trying to make my overlay background transparent with DwmExtendFrameIntoClientArea. I’ve tried the following code:
WNDCLASSEXW wc = { sizeof(wc), CS_VREDRAW | CS_HREDRAW, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"Example", NULL };
::RegisterClassExW(&wc);
HWND hwnd = ::CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_LAYERED, wc.lpszClassName, L"Example", WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, wc.hInstance, NULL);
SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 255, LWA_ALPHA);
MARGINS margin = { -1 };
DwmExtendFrameIntoClientArea(hwnd, &margin);
But all this does is draw my overlay on top of a black image, if I change the “255” attribute in SetLayeredWindowAttributes to 0, it does not draw anything.
Perhaps this has something to do with my computer running Windows 11.
Does anyone else have an idea? You might not be able to reproduce this.
1