| 1337 | } EnumDpiData; |
| 1338 | |
| 1339 | static int QueryDpiForMonitor(HMONITOR hmon, MONITOR_DPI_TYPE dpiType = MDT_DEFAULT) { |
| 1340 | int dpiX = 96, dpiY = 96; |
| 1341 | |
| 1342 | UINT x = 0, y = 0; |
| 1343 | if (hmon) { |
| 1344 | HRESULT hr = GetDpiForMonitor(hmon, dpiType, &x, &y); |
| 1345 | if (SUCCEEDED(hr) && (x > 0) && (y > 0)) { |
| 1346 | dpiX = (int)x; |
| 1347 | dpiY = (int)y; |
| 1348 | } |
| 1349 | } else { |
| 1350 | static int overallX = 0, overallY = 0; |
| 1351 | if (overallX <= 0 || overallY <= 0) { |
| 1352 | HDC hdc = GetDC(nullptr); |
| 1353 | if (hdc) { |
| 1354 | overallX = GetDeviceCaps(hdc, LOGPIXELSX); |
| 1355 | overallY = GetDeviceCaps(hdc, LOGPIXELSY); |
| 1356 | ReleaseDC(nullptr, hdc); |
| 1357 | } |
| 1358 | } |
| 1359 | if (overallX > 0 && overallY > 0) { |
| 1360 | dpiX = overallX; |
| 1361 | dpiY = overallY; |
| 1362 | } |
| 1363 | } |
| 1364 | |
| 1365 | return (dpiX + dpiY) / 2; |
| 1366 | } |
| 1367 | |
| 1368 | static BOOL CALLBACK _MonitorEnumProcDpi(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { |
| 1369 | EnumDpiData *data = (EnumDpiData *)dwData; |
no outgoing calls
no test coverage detected