bug report: enum all display devices (#8745)

This commit is contained in:
Andrey Nekrasov
2020-12-25 12:49:58 +03:00
committed by GitHub
parent ff74ef4a42
commit 0c300194dc
2 changed files with 23 additions and 26 deletions

View File

@@ -171,6 +171,7 @@ namespace FancyZonesUtils
}
typedef BOOL(WINAPI* GetDpiForMonitorInternalFunc)(HMONITOR, UINT, UINT*, UINT*);
std::wstring GetDisplayDeviceId(const std::wstring& device, std::unordered_map<std::wstring, DWORD>& displayDeviceIdxMap)
{
DISPLAY_DEVICE displayDevice{ .cb = sizeof(displayDevice) };

View File

@@ -5,38 +5,33 @@
int report(std::wostream& os)
{
struct capture
{
std::wostream* os = nullptr;
};
auto callback = [](HMONITOR monitor, HDC, RECT*, LPARAM prm) -> BOOL {
std::wostream& os = *(std::wostream*)prm;
std::wostream& os = *((capture*)prm)->os;
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
if (GetMonitorInfo(monitor, &mi))
if (GetMonitorInfoW(monitor, &mi))
{
os << "GetMonitorInfo OK\n";
DISPLAY_DEVICE displayDevice = { sizeof(displayDevice) };
if (EnumDisplayDevices(mi.szDevice, 0, &displayDevice, 1))
DWORD i = 0;
while (EnumDisplayDevicesW(mi.szDevice, i++, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME))
{
if (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)
{
os << "EnumDisplayDevices OK[MIRRORING_DRIVER]: \n"
<< "\tDeviceID = " << displayDevice.DeviceID << '\n'
<< "\tDeviceKey = " << displayDevice.DeviceKey << '\n'
<< "\tDeviceName = " << displayDevice.DeviceName << '\n'
<< "\tDeviceString = " << displayDevice.DeviceString << '\n';
}
else
{
os << "EnumDisplayDevices OK:\n"
<< "\tDeviceID = " << displayDevice.DeviceID << '\n'
<< "\tDeviceKey = " << displayDevice.DeviceKey << '\n'
<< "\tDeviceName = " << displayDevice.DeviceName << '\n'
<< "\tDeviceString = " << displayDevice.DeviceString << '\n';
}
}
else
{
auto message = get_last_error_message(GetLastError());
os << "EnumDisplayDevices FAILED: " << (message.has_value() ? message.value() : L"") << '\n';
const bool active = displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE;
const bool mirroring = displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER;
os << "EnumDisplayDevices OK:\n"
<< "\tMirroring = " << mirroring << '\n'
<< "\tActive = " << active << '\n'
<< "\tDeviceID = " << displayDevice.DeviceID << '\n'
<< "\tDeviceKey = " << displayDevice.DeviceKey << '\n'
<< "\tDeviceName = " << displayDevice.DeviceName << '\n'
<< "\tDeviceString = " << displayDevice.DeviceString << '\n';
}
}
else
@@ -46,8 +41,9 @@ int report(std::wostream& os)
}
return TRUE;
};
if (EnumDisplayMonitors(nullptr, nullptr, callback, (LPARAM)&os))
capture c;
c.os = &os;
if (EnumDisplayMonitors(nullptr, nullptr, callback, (LPARAM)&c))
{
os << "EnumDisplayMonitors OK\n";
}