修改以正确引入WinDevice项目
This commit is contained in:
parent
de8a41fff1
commit
50298ad6e8
2
.gitignore
vendored
2
.gitignore
vendored
@ -73,4 +73,6 @@ CMakeLists.txt.user*
|
||||
*.exe
|
||||
|
||||
.vscode
|
||||
.idea
|
||||
.vs
|
||||
|
||||
|
@ -9,13 +9,17 @@ set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# 设置源代码文件编码为UTF-8
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
||||
|
||||
# 添加sdplog目录
|
||||
include_directories(include/third_lib/spdlog)
|
||||
# 添加WinDevice目录
|
||||
include_directories(../WinDevice)
|
||||
include_directories(include/third_lib)
|
||||
|
||||
# 添加WinDevice项目
|
||||
add_subdirectory(../WinDevice WinDevice)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
main.cpp
|
||||
@ -48,6 +52,14 @@ else()
|
||||
endif()
|
||||
|
||||
target_link_libraries(DeviceManager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
# 链接WinDevice项目
|
||||
target_include_directories(DeviceManager PRIVATE
|
||||
../WinDevice
|
||||
)
|
||||
# 将WinDevice项目的头文件路径添加到DeviceManager项目中
|
||||
target_include_directories(DeviceManager PRIVATE
|
||||
../WinDevice/src # 根据实际路径进行修改
|
||||
)
|
||||
|
||||
set_target_properties(DeviceManager PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include "Video/ScreenManager.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
|
1
WinDevice/.gitignore
vendored
Normal file
1
WinDevice/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/cmake-*
|
@ -1,24 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
project(WinDevice)
|
||||
project(WinDevice VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
# 添加主项目的源文件
|
||||
add_executable(WinDevice
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# 设置头文件目录,包括spdlog头文件和功能模块的头文件目录
|
||||
target_include_directories(WinDevice PRIVATE
|
||||
include/
|
||||
include/third_lib/
|
||||
src/Audio/
|
||||
src/Video/
|
||||
src/Utils/
|
||||
)
|
||||
# 设置源代码文件编码为UTF-8
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
|
||||
|
||||
# 添加sdplog目录
|
||||
include_directories(include/third_lib)
|
||||
|
||||
# 添加功能模块的源文件
|
||||
target_sources(WinDevice PRIVATE
|
||||
src/Audio/*.cpp
|
||||
src/Video/*.cpp
|
||||
src/Utils/*.cpp
|
||||
set(PROJECT_SOURCES
|
||||
"src/Audio"
|
||||
"src/Video"
|
||||
"src/Utils"
|
||||
)
|
||||
|
@ -46,33 +46,33 @@ BOOL ScreenManager::_EnumMonitorProc(HMONITOR hMonitor)
|
||||
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
||||
if (GetMonitorInfo(hMonitor, &monitorInfo))
|
||||
{
|
||||
// 输出友好名称
|
||||
// 输出友好名称
|
||||
spdlog::info("_UpdateMonitorInfoMap, szDevice:{0}, right:{1}, bottom:{2}", Wchar2String(monitorInfo.szDevice),
|
||||
monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom);
|
||||
}
|
||||
auto it = ScreenManager::_hMonitorInfoMap.find(hMonitor);
|
||||
if (it != ScreenManager::_hMonitorInfoMap.end())
|
||||
{
|
||||
// 键已经存在,表示存在重复
|
||||
// 在这里处理重复的情况
|
||||
// 键已经存在,表示存在重复
|
||||
// 在这里处理重复的情况
|
||||
}
|
||||
else
|
||||
{
|
||||
ScreenManager::_hMonitorInfoMap.insert(std::make_pair(hMonitor, monitorInfo));
|
||||
// 键不存在,表示没有重复
|
||||
// 在这里处理非重复的情况
|
||||
// 键不存在,表示没有重复
|
||||
// 在这里处理非重复的情况
|
||||
}
|
||||
|
||||
DISPLAYCONFIG_TARGET_DEVICE_NAME targetDeviceName = {};
|
||||
targetDeviceName.header.size = sizeof(targetDeviceName);
|
||||
|
||||
// 获取指定 HMONITOR 的目标设备名称信息
|
||||
// 获取指定 HMONITOR 的目标设备名称信息
|
||||
if (DisplayConfigGetDeviceInfo(&targetDeviceName.header) == ERROR_SUCCESS)
|
||||
{
|
||||
spdlog::info("_UpdateMonitorInfoMap, monitorDevicePath:{0}, monitorFriendlyDeviceName:{1}",
|
||||
Wchar2String(targetDeviceName.monitorDevicePath), Wchar2String(targetDeviceName.monitorFriendlyDeviceName));
|
||||
|
||||
// 获取指定 HMONITOR 的分辨率信息
|
||||
// 获取指定 HMONITOR 的分辨率信息
|
||||
DEVMODE dm;
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
dm.dmDriverExtra = 0;
|
||||
@ -101,7 +101,7 @@ BOOL CALLBACK ScreenManager::EnumMonitorsProc(HMONITOR hMonitor, HDC hdcMonitor,
|
||||
void ScreenManager::_UpdateMonitorInfoMap()
|
||||
{
|
||||
spdlog::info("=====GetInfoByEnumDisplayMonitors start=====");
|
||||
// 枚举显示器
|
||||
// 枚举显示器
|
||||
EnumDisplayMonitors(nullptr, nullptr, EnumMonitorsProc, reinterpret_cast<LPARAM>(this));
|
||||
spdlog::info("=====GetInfoByEnumDisplayMonitors end=====");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user