#pragma once #include "gdiplus.h" template std::vector> GetAllMonitorRects() { using result_t = std::vector>; result_t result; auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL { MONITORINFOEX mi; mi.cbSize = sizeof(mi); result_t& result = *reinterpret_cast(param); if (GetMonitorInfo(monitor, &mi)) { result.push_back({ monitor, mi.*member }); } return TRUE; }; EnumDisplayMonitors(NULL, NULL, enumMonitors, reinterpret_cast(&result)); return result; } template std::vector> GetAllMonitorInfo() { using result_t = std::vector>; result_t result; auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL { MONITORINFOEX mi; mi.cbSize = sizeof(mi); result_t& result = *reinterpret_cast(param); if (GetMonitorInfo(monitor, &mi)) { result.push_back({ monitor, mi }); } return TRUE; }; EnumDisplayMonitors(NULL, NULL, enumMonitors, reinterpret_cast(&result)); return result; }