| 40 | } |
| 41 | |
| 42 | int DpiUtil::GetDpiForWindow(HWND window) |
| 43 | { |
| 44 | static auto GetDpiForMonitorFunc = []() { |
| 45 | return reinterpret_cast<decltype(&::GetDpiForMonitor)>( |
| 46 | ::GetProcAddress(GetShcoreModule(), "GetDpiForMonitor")); |
| 47 | }(); |
| 48 | if (GetDpiForMonitorFunc) |
| 49 | { |
| 50 | UINT dpi_x, dpi_y; |
| 51 | HMONITOR monitor = ::MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST); |
| 52 | CHECK_FAILURE(GetDpiForMonitorFunc(monitor, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y)); |
| 53 | return dpi_x; |
| 54 | } |
| 55 | else |
| 56 | { |
| 57 | return GetDeviceCaps(GetDC(nullptr), LOGPIXELSX); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | HMODULE DpiUtil::GetUser32Module() |
| 62 | { |
nothing calls this directly
no outgoing calls
no test coverage detected