Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetThreadDpiAwareness for host error dialog #81930

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
{
typedef DPI_AWARENESS_CONTEXT(WINAPI* set_thread_dpi)(DPI_AWARENESS_CONTEXT context);
elinor-fung marked this conversation as resolved.
Show resolved Hide resolved
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