修复编译运行错误

This commit is contained in:
DevWiki 2023-10-09 16:56:55 +08:00
parent 5c00047718
commit ef9faa08c7
3 changed files with 24 additions and 14 deletions

View File

@ -5,13 +5,23 @@
#include "Utils/StringUtil.h" #include "Utils/StringUtil.h"
void SceenManager::UpdateDisplayInfo() ScreenManager::ScreenManager()
{
}
ScreenManager::~ScreenManager()
{
}
void ScreenManager::UpdateDisplayInfo()
{ {
_UpdateDisplayDeviceList(); _UpdateDisplayDeviceList();
_UpdateMonitorInfoMap(); _UpdateMonitorInfoMap();
} }
void SceenManager::_UpdateDisplayDeviceList() void ScreenManager::_UpdateDisplayDeviceList()
{ {
spdlog::info("=====GetInfoByEnumDisplayDevices start====="); spdlog::info("=====GetInfoByEnumDisplayDevices start=====");
DISPLAY_DEVICE displayDevice; DISPLAY_DEVICE displayDevice;
@ -30,7 +40,7 @@ void SceenManager::_UpdateDisplayDeviceList()
spdlog::info("=====GetInfoByEnumDisplayDevices end====="); spdlog::info("=====GetInfoByEnumDisplayDevices end=====");
} }
BOOL SceenManager::_EnumMonitorProc(HMONITOR hMonitor) BOOL ScreenManager::_EnumMonitorProc(HMONITOR hMonitor)
{ {
MONITORINFOEX monitorInfo; MONITORINFOEX monitorInfo;
monitorInfo.cbSize = sizeof(MONITORINFOEX); monitorInfo.cbSize = sizeof(MONITORINFOEX);
@ -40,15 +50,15 @@ BOOL SceenManager::_EnumMonitorProc(HMONITOR hMonitor)
spdlog::info("_UpdateMonitorInfoMap, szDevice:{0}, right:{1}, bottom:{2}", Wchar2String(monitorInfo.szDevice), spdlog::info("_UpdateMonitorInfoMap, szDevice:{0}, right:{1}, bottom:{2}", Wchar2String(monitorInfo.szDevice),
monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom); monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom);
} }
auto it = SceenManager::_hMonitorInfoMap.find(hMonitor); auto it = ScreenManager::_hMonitorInfoMap.find(hMonitor);
if (it != SceenManager::_hMonitorInfoMap.end()) if (it != ScreenManager::_hMonitorInfoMap.end())
{ {
// 键已经存在,表示存在重复 // 键已经存在,表示存在重复
// 在这里处理重复的情况 // 在这里处理重复的情况
} }
else else
{ {
SceenManager::_hMonitorInfoMap.insert(std::make_pair(hMonitor, monitorInfo)); ScreenManager::_hMonitorInfoMap.insert(std::make_pair(hMonitor, monitorInfo));
// 键不存在,表示没有重复 // 键不存在,表示没有重复
// 在这里处理非重复的情况 // 在这里处理非重复的情况
} }
@ -73,7 +83,7 @@ BOOL SceenManager::_EnumMonitorProc(HMONITOR hMonitor)
} }
else else
{ {
spdlog::info(L"Failed to get display resolution."); spdlog::info("Failed to get display resolution.");
} }
} }
else else
@ -83,12 +93,12 @@ BOOL SceenManager::_EnumMonitorProc(HMONITOR hMonitor)
return TRUE; return TRUE;
} }
BOOL CALLBACK SceenManager::EnumMonitorsProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) BOOL CALLBACK ScreenManager::EnumMonitorsProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{ {
return ((SceenManager*)dwData)->_EnumMonitorProc(hMonitor); return ((ScreenManager*)dwData)->_EnumMonitorProc(hMonitor);
} }
void SceenManager::_UpdateMonitorInfoMap() void ScreenManager::_UpdateMonitorInfoMap()
{ {
spdlog::info("=====GetInfoByEnumDisplayMonitors start====="); spdlog::info("=====GetInfoByEnumDisplayMonitors start=====");
// 枚举显示器 // 枚举显示器

View File

@ -4,11 +4,11 @@
#include <Mmdeviceapi.h> #include <Mmdeviceapi.h>
class SceenManager class ScreenManager
{ {
public: public:
SceenManager(); ScreenManager();
~SceenManager(); ~ScreenManager();
void UpdateDisplayInfo(); void UpdateDisplayInfo();
private: private:

View File

@ -18,7 +18,7 @@ int main()
{ {
const std::string command = "wmic desktopmonitor get PNPDeviceId,ScreenWidth,ScreenHeight"; const std::string command = "wmic desktopmonitor get PNPDeviceId,ScreenWidth,ScreenHeight";
const std::string command_output = CmdUtil::ExecuteCommand(command); const std::string command_output = CmdUtil::ExecuteCommand(command);
SceenManager sceen_manager; ScreenManager sceen_manager;
sceen_manager.UpdateDisplayInfo(); sceen_manager.UpdateDisplayInfo();
} }