Fix constructing of monitor

This commit is contained in:
BlackMark 2020-07-05 17:55:23 +02:00
parent 3361dcf088
commit 1e7e0b4e6d
2 changed files with 15 additions and 3 deletions

View File

@ -2,6 +2,7 @@
#ifdef _MSC_VER
#include <string>
#include <vector>
#include <physicalmonitorenumerationapi.h>
@ -18,12 +19,19 @@ class Monitor {
Monitor() = delete;
private:
struct PhysicalMonitor {
PhysicalMonitor(HANDLE handle, const WCHAR* name) : handle(handle), name(name) {}
HANDLE handle;
std::wstring name;
};
friend BOOL detail::enumMonitorsCallback(HMONITOR, HDC, LPRECT, LPARAM);
Monitor(HMONITOR hMonitor, PHYSICAL_MONITOR hPhysicalMonitor);
Monitor(HMONITOR hMonitor, PHYSICAL_MONITOR physicalMonitor);
const HMONITOR m_hMonitor;
const PHYSICAL_MONITOR m_physicalMonitor;
const PhysicalMonitor m_physicalMonitor;
};
#endif

View File

@ -2,6 +2,10 @@
#ifdef _MSC_VER
Monitor::Monitor(HMONITOR hMonitor, PHYSICAL_MONITOR hPhysicalMonitor) : m_hMonitor(hMonitor), m_physicalMonitor(m_physicalMonitor) {}
Monitor::Monitor(HMONITOR hMonitor, PHYSICAL_MONITOR physicalMonitor)
: m_hMonitor(hMonitor)
, m_physicalMonitor(physicalMonitor.hPhysicalMonitor, physicalMonitor.szPhysicalMonitorDescription)
{
}
#endif