Revert "SetThreadDpiAwareness for host error dialog (#81930)" (#85773)
authorElinor Fung <elfung@microsoft.com>
Thu, 4 May 2023 21:34:20 +0000 (23:34 +0200)
committerGitHub <noreply@github.com>
Thu, 4 May 2023 21:34:20 +0000 (23:34 +0200)
This reverts commit 6f36be56480dc0a24a9713df5d81875a9ca2c980.

There is an issue with the Windows TaskDialog where expanding/collapsing the detail area will result in incorrect resizing of the window when the DPI awareness of the process and thread are not the same. Instead of explicitly making the thread starting the dialog DPI aware, we just leave it whatever the process is set to. This means that if the developer specified a manifest that made their application DPI aware, the dialog will be non-blurry, but if the developer did not, it will remain blurry on high DPI.

src/native/corehost/apphost/apphost.windows.cpp

index e0dd4d7f52adaee586aa4c322de9c22825ebf4cb..43abe909e776fa95753fc31b0040ed1d614ded7c 100644 (file)
@@ -323,20 +323,6 @@ namespace
 
         trace::verbose(_X("Showing error dialog for application: '%s' - error code: 0x%x - url: '%s' - details: %s"), executable_name, error_code, url.c_str(), details.c_str());
 
-        HMODULE user32 = ::LoadLibraryExW(L"user32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
-        if (user32 != nullptr)
-        {
-            using set_thread_dpi = DPI_AWARENESS_CONTEXT(WINAPI*)(DPI_AWARENESS_CONTEXT context);
-            set_thread_dpi set_thread_dpi_func = (set_thread_dpi)::GetProcAddress(user32, "SetThreadDpiAwarenessContext");
-
-            // Since this is only for errors shown when the process is about to exit, we
-            // skip resetting to the previous context to minimize impact on apphost size
-            if (set_thread_dpi_func != nullptr)
-                (void) set_thread_dpi_func(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
-    
-            ::FreeLibrary(user32);
-        }
-
         if (enable_visual_styles())
         {
             // Task dialog requires enabling visual styles