How to identify a widescreen monitor in Windows

I need a way to programmatically determine if a monitor is wide or not in Windows.

GetSystemMetrics returns a desktop size that works, but if the user has a widescreen monitor, say, 1024x768, I incorrectly classify it as not wide.

GetDeviceCaps has similar problems with HORZRES and VERTRES, and even HORZSIZE AND VERTSIZE give incorrect results when wide resolution is used for a wide monitor.

Is there any way to detect this reliably?

+3
source share
4 answers

, EDID. . : ?

+4

, EDID . ( ), , , .

DEVMODEA modeInfo;
modeInfo.dmSize = sizeof(DEVMODEA);
modeInfo.dmDriverExtra = NULL;
int modeNum = 0;
int xMax = 0, yMax = 0;
while (EnumDisplaySettingsExA(0, modeNum, &modeInfo, 0)) {
    ++modeNum;
    if (modeInfo.dmPelsWidth > xMax) {
        xMax = modeInfo.dmPelsWidth;
        yMax = modeInfo.dmPelsHeight;
    }
}
cout << "Monitor aspect ratio : " << (double)xMax/yMax << "\n";

.

+2

SystemInformation.PrimaryMonitorSize

0

. , .

, . - .

0

Source: https://habr.com/ru/post/1718558/


All Articles