有两个监视器:次要监视器位于主监视器的左侧。决议:
Primary: 2560*1440 scaling 100%
Secondary: 1920*1200 scaling 150%
在程序启动时,它执行 EnumDisplayMonitors
,它提供以下 RECT:
Primary: 0,0,2560,1440
Secondary: -1920,0,-640,800
我也试过代码:
int width, height;
RECT rect = { -1920, 0, -640, 800 };
SystemParametersInfoA(SPI_SETWORKAREA, 0, &rect, 0);
width = GetSystemMetrics(SM_CXSCREEN);
height = GetSystemMetrics(SM_CYSCREEN);
但是 width
和 height
始终具有主监视器的尺寸。
如何检测辅助显示器的原始分辨率 1920*1200
或缩放因子 150%
?
这也不起作用,给出 1280*800
:
BOOL CALLBACK EnumMonitorCallback(HMONITOR hMon, HDC hdc, LPRECT rect, LPARAM param)
{
MONITORINFOEXA mi;
mi.cbSize = sizeof(mi);
GetMonitorInfoA(hMon, &mi);
HDC dc = CreateDCA("DISPLAY", mi.szDevice, NULL, NULL);
int width = GetDeviceCaps(dc, HORZRES);
int height = GetDeviceCaps(dc, VERTRES);
DeleteDC(dc);
return TRUE;
}
最佳答案
GetSystemMetrics
调用 SM_CXSCREEN
或 SM_CYSCREEN
将返回主显示器的分辨率。要获得辅助显示器的分辨率,您需要使用 GetDeviceCaps
或 Multiple Display Monitors API .
关于c++ - 如何在 Windows 10 上检测辅助显示器的 native 屏幕分辨率或比例因子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54581535/