Early DPI awareness

This commit is contained in:
momo5502 2023-01-30 18:38:41 +01:00
parent 10cbf6a8bc
commit f2924eee05
2 changed files with 15 additions and 15 deletions

View File

@ -25,19 +25,6 @@ namespace splash
return utils::image::create_bitmap(img); return utils::image::create_bitmap(img);
} }
void enable_dpi_awareness()
{
const utils::nt::library user32{"user32.dll"};
const auto set_dpi = user32
? user32.get_proc<BOOL(WINAPI*)(DPI_AWARENESS_CONTEXT)>(
"SetProcessDpiAwarenessContext")
: nullptr;
if (set_dpi)
{
set_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
}
}
void destroy_window() void destroy_window()
{ {
if (window && IsWindow(window)) if (window && IsWindow(window))
@ -169,8 +156,6 @@ namespace splash
{ {
component() component()
{ {
enable_dpi_awareness();
image = load_splash_image(); image = load_splash_image();
window_thread = std::thread([this] window_thread = std::thread([this]
{ {

View File

@ -170,6 +170,19 @@ namespace
return true; return true;
} }
void enable_dpi_awareness()
{
const utils::nt::library user32{ "user32.dll" };
const auto set_dpi = user32
? user32.get_proc<BOOL(WINAPI*)(DPI_AWARENESS_CONTEXT)>(
"SetProcessDpiAwarenessContext")
: nullptr;
if (set_dpi)
{
set_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
}
}
int main() int main()
{ {
if (handle_process_runner()) if (handle_process_runner())
@ -180,6 +193,8 @@ namespace
FARPROC entry_point{}; FARPROC entry_point{};
srand(uint32_t(time(nullptr)) ^ ~(GetTickCount() * GetCurrentProcessId())); srand(uint32_t(time(nullptr)) ^ ~(GetTickCount() * GetCurrentProcessId()));
enable_dpi_awareness();
{ {
auto premature_shutdown = true; auto premature_shutdown = true;
const auto _ = utils::finally([&premature_shutdown] const auto _ = utils::finally([&premature_shutdown]