修改以正确引入WinDevice项目

This commit is contained in:
DevWiki 2023-10-10 11:54:29 +08:00
parent de8a41fff1
commit 50298ad6e8
6 changed files with 44 additions and 28 deletions

2
.gitignore vendored
View File

@ -73,4 +73,6 @@ CMakeLists.txt.user*
*.exe
.vscode
.idea
.vs

View File

@ -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
)
# WinDeviceDeviceManager
target_include_directories(DeviceManager PRIVATE
../WinDevice/src #
)
set_target_properties(DeviceManager PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com

View File

@ -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
View File

@ -0,0 +1 @@
/cmake-*

View File

@ -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)
# spdlog
target_include_directories(WinDevice PRIVATE
include/
include/third_lib/
src/Audio/
src/Video/
src/Utils/
)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 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"
)

View File

@ -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=====");
}