Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-10-10 11:38:20 +08:00
parent 7cc51b8c2e
commit 5087c473f6
1 changed files with 19 additions and 17 deletions

View File

@ -671,21 +671,8 @@ UINT GetDotsPerInchForSystem()
return WNEF_EXECUTE_WINAPI_RETURN(GetSystemDpiForProcess, return WNEF_EXECUTE_WINAPI_RETURN(GetSystemDpiForProcess,
0, 0,
WNEF_EXECUTE_WINAPI_RETURN(GetCurrentProcess, nullptr)); WNEF_EXECUTE_WINAPI_RETURN(GetCurrentProcess, nullptr));
} else if (m_lpGetDpiForMonitor) { }
UINT dpiX = m_defaultDotsPerInch, dpiY = m_defaultDotsPerInch; if (m_lpGetDpiForSystem) {
/*
WNEF_EXECUTE_WINAPI(GetDpiForMonitor,
WNEF_EXECUTE_WINAPI_RETURN(MonitorFromWindow,
nullptr,
handle,
MONITOR_DEFAULTTONEAREST),
MDT_EFFECTIVE_DPI,
&dpiX,
&dpiY)
*/
// The values of *dpiX and *dpiY are identical.
return dpiX == dpiY ? dpiY : dpiX;
} else if (m_lpGetDpiForSystem) {
return WNEF_EXECUTE_WINAPI_RETURN(GetDpiForSystem, 0); return WNEF_EXECUTE_WINAPI_RETURN(GetDpiForSystem, 0);
} }
return getScreenDpi(m_defaultDotsPerInch); return getScreenDpi(m_defaultDotsPerInch);
@ -698,9 +685,24 @@ UINT GetDotsPerInchForWindow(const HWND handle)
// Return hard-coded DPI if DPI scaling is disabled. // Return hard-coded DPI if DPI scaling is disabled.
return m_defaultDotsPerInch; return m_defaultDotsPerInch;
} }
if (m_lpGetDpiForWindow && WNEF_EXECUTE_WINAPI_RETURN(IsWindow, FALSE, handle)) { if (WNEF_EXECUTE_WINAPI_RETURN(IsWindow, FALSE, handle)) {
if (m_lpGetDpiForWindow) {
return WNEF_EXECUTE_WINAPI_RETURN(GetDpiForWindow, 0, handle); return WNEF_EXECUTE_WINAPI_RETURN(GetDpiForWindow, 0, handle);
} }
if (m_lpGetDpiForMonitor) {
UINT dpiX = m_defaultDotsPerInch, dpiY = m_defaultDotsPerInch;
WNEF_EXECUTE_WINAPI(GetDpiForMonitor,
WNEF_EXECUTE_WINAPI_RETURN(MonitorFromWindow,
nullptr,
handle,
MONITOR_DEFAULTTONEAREST),
MDT_EFFECTIVE_DPI,
&dpiX,
&dpiY)
// The values of *dpiX and *dpiY are identical.
return dpiX == dpiY ? dpiY : dpiX;
}
}
return GetDotsPerInchForSystem(); return GetDotsPerInchForSystem();
} }