locked
SetWindowDisplayAffinity bug RRS feed

  • Question

  • SetWindowDisplayAffinity(handle, WDA_MONITOR) Bug in all 20h1 including "RTM" build 19043.208, it does not make Window blacked. WDA_EXCLUDEFROMCAPTURE should do this not WDA_MONITOR, looks like both do the same. In my opinion it's a bug, anyone has 20h1 and can confirm?
     




    • Edited by jms123123 Wednesday, June 10, 2020 6:05 PM
    Friday, May 1, 2020 3:32 PM

All replies

  • Hi,

    I can get it work in the latest build 19619.1000.

    Try to update the OS.

    Best Regards,

    Drake


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 5, 2020 4:38 AM
  • Hi,

    I can get it work in the latest build 19619.1000.

    Try to update the OS.

    Best Regards,

    Drake


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Are you trolling right now yes or what?
    Why you advice me to test early preview build which is not mentioned in my post?

    I'm talking about obvious issue in Windows 2020 May (19043 build ) Update comming soon.
    This build has status "RTM" as I could read there: https://blogs.windows.com/windowsexperience/2020/04/30/getting-the-may-2020-update-ready-for-release-updated/

    We do not talk there about "20H2" next update early preview build,
    but I mean the latest build 19043.208 (actually for this day all 19043 compilations) - that it's buggy obviously.

    Any Microsoft developer read this forum?









    • Edited by jms123123 Wednesday, May 6, 2020 10:16 AM
    Tuesday, May 5, 2020 9:28 AM
  • Hi,

    Sorry for the last reply, and I have also tested it in the build that metioned in your link(19041.208).

    It also works for me. Here is my test sample:

    #include <windows.h>
    #include <iostream>
    using namespace std;
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)
        {
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
            // TODO: Add any drawing code that uses hdc here...
            EndPaint(hWnd, &ps);
        }
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        return 0;
    }
    int main()
    {
        DWORD dwAffinity;
        WNDCLASSEXW wcex = { 0 };
        BOOL ret = 0;
        wcex.cbSize = sizeof(WNDCLASSEXW);
    
        wcex.style = CS_HREDRAW | CS_VREDRAW;
        wcex.lpfnWndProc = WndProc;
        wcex.cbClsExtra = 0;
        wcex.cbWndExtra = 0;
        wcex.hInstance = GetModuleHandle(NULL);
        wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
        wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
        wcex.lpszClassName = L"Test_class";
    
        RegisterClassExW(&wcex);
    
        HWND hWnd = CreateWindowW(L"Test_class", L"Test Window", WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, GetModuleHandle(NULL), nullptr);
        if (!hWnd)
        {
            return FALSE;
        }
        ret = GetWindowDisplayAffinity(hWnd, &dwAffinity);
        ret = SetWindowDisplayAffinity(hWnd, WDA_EXCLUDEFROMCAPTURE);
        ShowWindow(hWnd, SW_SHOW);
        UpdateWindow(hWnd);
    
        MSG msg;
    
        // Main message loop:
        while (GetMessageW(&msg, nullptr, 0, 0))
        {
            if (!TranslateAcceleratorW(msg.hwnd, 0, &msg))
            {
                TranslateMessage(&msg);
                DispatchMessageW(&msg);
            }
        }
        return 0;
    }

    Could you please share the sample you have tried?

    Best Regards,

    Drake


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 6, 2020 5:30 AM
  • Thank you for checking but unfortunately still you seems do not understand the problem :(
    Your code not only does not work but It cannot work by design.

     ret = SetWindowDisplayAffinity(hWnd, WDA_EXCLUDEFROMCAPTURE);

    WDA_EXCLUDEFROMCAPTURE Is excluding (transparent), which of course make window transparent but my post was about BLACK window from WDA_MONITOR. 
    Please notice that you put in your code  WDA_EXCLUDEFROMCAPTURE and not WDA_MONITOR....
    Can you please read my initial post again and make sure you understand it?
    Maybe I should explain as simple as possible..

    Here is my even simpler explanation:
    1. Change in your code

    ret = SetWindowDisplayAffinity(hWnd, WDA_EXCLUDEFROMCAPTURE);


    to:

    ret = SetWindowDisplayAffinity(hWnd, WDA_MONITOR);


    2. Make screen shot

    3. Sample Window form is NOT blacked (current result on "19043"), it's transparent (not included in screenshot) instead, but expected result is this form "blacked"

    Correct flow should be: 
    WDA_EXCLUDEFROMCAPTURE - transparent to screen shot
    WDA_MONITOR - BLACK window to screen shot

    With this bug both parameters  WDA_EXCLUDEFROMCAPTURE and WDA_MONITOR do the same (transparent)!

    19043 seems to be  buggy in all builds from .1 to .208 

    Can you please pass this to Windows Desktop developers as fatal bug? So they can fix before very official release in next patch.

    First time this API is going to be broken since Windows 7 release(only in 2020 may update)




    • Edited by jms123123 Wednesday, May 6, 2020 1:54 PM
    Wednesday, May 6, 2020 10:29 AM
  • Yes. I can confirm this issue, and have submitted it internally. I will update here if there is any progress.

    Best Regards,

    Drake


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 7, 2020 2:10 AM
  • Thank you for patience, I hope I was helpful, and pardon for calling your post trolling, but I was little frustrated already reported that before and it was ignored probably.

    Good that finally some desktop devs will look into this.
    I suspect bug in dwmcore.dll or dwm.exe components.

    Thursday, May 7, 2020 1:57 PM
  • Update:

    Internal engineers have confirmed that this may be a potential issue. I will continue to follow up the progress of this case.

    Best Regards,

    Drake


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 12, 2020 6:12 AM
  • Thank you for update.

    I thought they will fix it in today's patch tuesday, as for confirmations I have confirmed it myself over 4 weeks ago, you also there recently. 
    We need fix from devs more than "confirmations" 

    today's 19041.264 does not fixes that !- Just confirmed that bug still exist.

    Anyway it's good that somebody FINALLY reacts anyhow.

    I hope to see patch for this in next roll out minor update.






    • Edited by jms123123 Tuesday, May 12, 2020 5:52 PM
    Tuesday, May 12, 2020 9:48 AM
  • Hi,

    Update:

    Still confirm with the engineers, this behavior is not reproducible in latest build 19624.1000(WDA_MONITOR makes the window black when taking a screenshot) so we propose this issue has been fixed.

    Best Regards,

    Drake


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 13, 2020 7:02 AM
  • Excuse me, your post looks like you are trying to foolish readers ? ?


     We are talking there about the latest Windows which is going to be released not early preview.

    Who cares now about 20h2 (second 2020 major update) when we have current reality and comming May Update.? I perfectly know this what you wrote in the last post and it was mentioned already in previous posts in this thread, case is about 2020 May Update.

    Please don't try to manipulate readers, bug is NOT fixed, nobody now cares about 19624 very early previews, I talk there about current reality.





    • Edited by jms123123 Wednesday, May 13, 2020 3:01 PM
    Wednesday, May 13, 2020 1:40 PM
  • Hi Jms123123,

    Thanks for sharing this feedback with us.

    I am trying to report this issue, and with keep post here once there is any update. Sorry for the inconvenient.

    Regards & Fei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 18, 2020 5:41 AM
  • Hi Jms123123,

    Thanks for sharing this feedback with us.

    I am trying to report this issue, and with keep post here once there is any update. Sorry for the inconvenient.

    Regards & Fei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thanks, let me present my point of view again.

    This looks more like a tragicomedy, flows as follow:

    - I report issue
    - Reply keep telling there is no issue 
    - Finally someone admit there is problem and that it's reported
    - I ask for fix, someone telliing that it's fixed actually, where clearly it's not
    - Someone other person now "trying to report" this issue.. So previously it was not reported ? 

    Oh and forgot the most important fact probably, it's common with new API introduction parameter (WDA_EXCLUDEFROMCAPTURE) which is even more strange, someone has added new API with the bug at begening (breaking existing) more strange when you realize it's worth to at least make basic testing after new option was done.
    Looks so creepy to me whole process, I realize it's corporation and procedures are complicated but sorry I can't understnad this kind of logic :) Fix is probably trivial easy and fast for devs.

    Thanks for attention.

    Wednesday, May 20, 2020 10:13 PM
  • Hi Jms123123,

    Thanks for sharing this comments. I totally understand your feeling, however we are trying our best to feedback this issue. But there is no guaranteed which release will fix this issue. 

    Actually, Drake do report this issue to me, and I also discussed this issue with other support engineers, and based on our testing, this issue was fixed on Build 19628.1

    If this issue has a huge impact on your business, I also recommend you submit the feedback directly via Feedback Hub. And you can also share the feedback URL on this site, so that anyone who have same problem will help vote on this feedback. Then the product team can evaluate the impact of this issue and fix it as soon as possible. Below is the screenshot that I report this issue internally for you reference:
     

    Regards & Fei



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, May 21, 2020 2:39 AM
  • Hi Jms123123,

    Thanks for sharing this comments. I totally understand your feeling, however we are trying our best to feedback this issue. But there is no guaranteed which release will fix this issue. 

    Actually, Drake do report this issue to me, and I also discussed this issue with other support engineers, and based on our testing, this issue was fixed on Build 19628.1

    If this issue has a huge impact on your business, I also recommend you submit the feedback directly via Feedback Hub. And you can also share the feedback URL on this site, so that anyone who have same problem will help vote on this feedback. Then the product team can evaluate the impact of this issue and fix it as soon as possible. Below is the screenshot that I report this issue internally for you reference:
     

    Regards & Fei



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Actually now lost any hope and find my posting as waste of time, first of all it was reported over 4 weeks ago via HUB so there was lof of time to look into, second you keep repeating the same story, no it's not fixed. Can you tell me please who cares  now about 20h2 very early preview when we have 20h1 real in few days and oficially starts update distribution among Windows 10 Users via Windows Update.




    • Edited by jms123123 Thursday, May 21, 2020 11:02 AM
    Thursday, May 21, 2020 7:31 AM
  • The latest 10.0.19041.329 does not fixes problem, unfortunately despite reporting via HUB and there...

    What is more strange here:
    For my personal opinion it looks like new API was added without even testing it  :-(






    • Edited by jms123123 Wednesday, June 10, 2020 6:06 PM
    Wednesday, June 10, 2020 11:23 AM
  • Unfortunately there is more to getting this kind of patch into current and previous release versions of Windows. It may not be a case of one patch fixes all. The 21h1 implementation of SetWindowDisplayAffinity may be different to 2004, which may be different to 1903, which may be different to 1809 which may be different to 1803.

    The engineers will have other work that they need to do, which include existing bugs that they have to test and fix, other tickets that existed before your report and depending on how many people complain, there may be newer things which affect a lot more people going onto that list. Depending on the amount of work, it may take a couple of months for this to get fixed in a patch and it may just not be fixed in the currently released versions of Windows at all.

    Also, SetWindowDisplayAffinity isn't new. It was added along with Windows 7, but because DWM is integrated with Direct3D and the display driver model is updated regularly (currently WDDM 2.7), it is always possible for bugs to creep in.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Thursday, June 11, 2020 4:03 AM
  • @Darran Rowe, I cannot agree about differences, it's the same from Windows 7 and all releases of w10 so far.

    In 20H1 was introduced new parameter first time (WDA_EXCLUDEFROMCAPTURE) and the at the same time previous (WDA_MONITOR) stopped working as expected, that's why it looks to me strange. Nothing else, I do not comment other bugs and critial priority isses which obviously are tons of. Anyway IMHO this should be also fixed in some  cummulative patch without waiting for 20H2

    Friday, June 12, 2020 10:23 AM
  • @Drake_Wu,
    @Darran Rowe,

    :( unfortunately still not fixed with the latest .388 build

    • Edited by jms123123 Tuesday, July 14, 2020 8:28 PM
    Tuesday, July 14, 2020 8:26 PM