I need help on how to retrieve the resolutions of my screens, as shown in the image below.
I found this documentation and it was really helpful. Here's the code that I tried, based on those docs:
int numberOfScreens = GetSystemMetrics(SM_CMONITORS);
int width = GetSystemMetrics(SM_CXSCREEN);
int height = GetSystemMetrics(SM_CYSCREEN);
std::cout << "Number of monitors: " << numberOfScreens << "\n"; // returns 3
std::cout << "Width:" << width << "\n";
std::cout << "Height:" << height << "\n";
However, it only identifies and gives information about the main monitor. How do I get information about the other monitors?
#include <Windows.h>
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor,
HDC hdcMonitor,
LPRECT lprcMonitor,
LPARAM dwData)
{
MONITORINFO info;
info.cbSize = sizeof(info);
if (GetMonitorInfo(hMonitor, &info))
{
std::cout << "Monitor x: "<< std::abs(info.rcMonitor.left - info.rcMonitor.right)
<<" y: " << std::abs(info.rcMonitor.top - info.rcMonitor.bottom)
<< std::endl;
}
return TRUE; // continue enumerating
}
int main()
{
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, 0);
return 0;
}