I'm trying to create a fully transparent window, which also has click-through behavior, except for the few UI controls on it.
All works well in principle, but I just noticed that click-through only works for certain transparency color keys. Red and blue must be equal, green doesn't matter and can be anything. Transparency seems to work for all color keys. The only hint I found was an old article about Windows 7 Aero themes interfering with specific colors. But I'm on Windows 11 and I couldn't figure out what's going on.
Does anybody know what causes this behavior and how it can be worked around? Thanks!
COLORREF const TRANS_COLOR = RGB(0xFF, 0, 0xFF); // works
//COLORREF const TRANS_COLOR = RGB(0, 0xFF, 0xFF); // doesn't work!
...
hWndMain = CreateWindowEx(WS_EX_TOPMOST, szWndClassMain, szWndTitleMain, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInst, NULL);
//SetWindowLong(hWndMain, GWL_EXSTYLE, GetWindowLong(hWndMain, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
SetWindowLong(hWndMain, GWL_EXSTYLE, GetWindowLong(hWndMain, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hWndMain, TRANS_COLOR, 0, LWA_COLORKEY);
...
WNDCLASS wc;
wc.hbrBackground = CreateSolidBrush(TRANS_COLOR);
...
RegisterClass(&wc);