It's an unexpected behavior and I'm reporting it. It's recommended to avoid using child window with WS_EX_LAYERED as @Castorix31 suggested.
As this issue is complex, please open an incident via 'Contact us' tab at link below so that our engineer can work with you closely: https://developer.microsoft.com/en-us/windows/support/ and please choose the 'Technical Support - Coding/Debugging' for Windows SDK for this issue. In-addition, if the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged.
How to stop WS_EX_LAYERED causing mouse clicks to go through.
WS_EX_LAYERED shouldn't usually pass mouse clicks according to the documentation. Yet it does. It basically has the same effect as WS_EX_TRANSPARENT.
This happens no matter what the opacity value is when using SetLayeredWindowAttributes(). However, this only happens when I use a manifest file to list the supported OSs(windows 8 and up).
The reason the manifest file is necessary is because that's the way to support child windows from having extended styles(this is needed to give translucency to child windows).
I have been trying to fix this/trying other ways to get the desired effects for roughly a week, but all was in vain.
One more thing. The non-client area remains unaffected initially but passes mouse clicks after minimizing. Here is a video showcasing this---> https://i.stack.imgur.com/USBUm.gif
I compile through GCC after linking the manifest file through .res and DLLs. Here is the makefile --> https://pastebin.com/yv5HqWBM
Manifest file --> https://pastebin.com/1RbcK3t7
Full code --> https://pastebin.com/s2NGh2CB
Here is the WM_CREATE code(in case you don't want to see the entire code)
case WM_CREATE:
SetWindowLongA(hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED);
SetLayeredWindowAttributes(hwnd, RGB(255, 0, 0), 0 /*doesn't matter*/, LWA_COLORKEY);
hbackground = CreateWindowExA(0,
"STATIC",
NULL,
WS_CHILD | WS_VISIBLE | SS_BITMAP,
0,
0,
window_width,
window_height,
hwnd,
NULL,
NULL,
(LPVOID)NULL);
setImage(hbackground, background_image_name, monitor_dimension.width, monitor_dimension.height);
SetWindowLongA(hbackground, GWL_EXSTYLE, GetWindowLongA(hbackground, GWL_EXSTYLE) | WS_EX_LAYERED);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED);
SetLayeredWindowAttributes(hbackground, 0, (255 * 50) / 100, LWA_ALPHA);
break;
1 answer
Sort by: Most helpful
-
Xiaopo Yang - MSFT 12,726 Reputation points Microsoft Vendor
2022-11-29T07:47:31.61+00:00