Window transparency in Windows 11

T B 66 Reputation points
2023-05-13T18:06:34.6866667+00:00

Hi, I had a working example on windows 8 of a transparent window, I don't remember exactly if it used UpdateLayeredWindow or AlphaBlend, the idea was to use crKey as the transparency color. I have only the exe file, and if I open it on windows 11 there is no transparency. What could be causing this behaviour ? I have tried:

        //UpdateLayeredWindow(hwnd, hdc, &ptDest, &client, hdc1, &ptSrc, RGB(0, 0, 0), &blendFunc, ULW_COLORKEY);
        AlphaBlend(hdc, 0, 0, rect.right - rect.left, rect.bottom - rect.top, hdc1, 0, 0, rect.right - rect.left, rect.bottom - rect.top, blendFunc);

Thankyou in advance!

Windows development Windows API - Win32
Developer technologies C++
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,681 Reputation points
    2023-05-13T19:45:14.1166667+00:00

    UpdateLayeredWindow works on Windows 11 : I had uploaded a test in WinUI 3/C# : https://github.com/castorix/WinUI3_SwapChainPanel_Layered

    and people told me it worked on Windows 11 but that I needed to add DwmSetWindowAttribute for borders/shadow

    Or you can also test this sample I had posted in C++, which could have borders because I did not use DwmSetWindowAttribute :

    https://learn.microsoft.com/en-us/answers/questions/639888/how-to-make-transparent-window-using-updatelayered?orderby=newest

    [Edit] I just saw this thread was from you : so this sample, with the same jpg and white transparent color, is not transparent on Windows 11 ?


1 additional answer

Sort by: Most helpful
  1. T B 66 Reputation points
    2023-07-01T12:32:03.55+00:00

    I am still looking for an answer. This code works on windows 8 when using RHI SM5 and ES31, but on windows 11 only with vulkan. I am using Unreal Engine. Any idea how to fix this ? Same thing using UpdateLayeredWindow

            DwmExtendFrameIntoClientArea(hwnd, &margins);
            SetLayeredWindowAttributes( hwnd, 0x00000000, FMath::TruncToInt( 1 * 255.0f ), LWA_ALPHA );
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.