Created
April 15, 2020 19:51
-
-
Save kaimingguo/f812ab420772c7f09e8bfd733c849345 to your computer and use it in GitHub Desktop.
Win32 API multi-monitor display information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <iostream> | |
#include <vector> | |
struct ScreenArray { | |
std::vector<RECT> Monitors; | |
static BOOL CALLBACK MonitorEnumProc(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) { | |
MONITORINFOEX mi = {0}; | |
mi.cbSize = sizeof(MONITORINFOEX); | |
GetMonitorInfo(monitor, &mi); | |
if (mi.dwFlags == DISPLAY_DEVICE_MIRRORING_DRIVER) { | |
std::cout << "Using mirroring driver for multi-screen." << std::endl; | |
} else { | |
auto p = reinterpret_cast<ScreenArray *>(data); | |
p->Monitors.push_back(*rect); | |
} | |
return TRUE; | |
} | |
ScreenArray() { | |
Monitors.empty(); | |
EnumDisplayMonitors(nullptr, nullptr, MonitorEnumProc, (LPARAM)this); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: https://stackoverflow.com/questions/26541484/enumdisplaymonitors-callback