Skip to content

Commit

Permalink
SetThreadDpiAwareness for host error dialog (#81930)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung authored Feb 13, 2023
1 parent b4c1a09 commit 6f36be5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/native/corehost/apphost/apphost.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,20 @@ 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
Expand Down

0 comments on commit 6f36be5

Please sign in to comment.