mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
refactor: 减少全局包含文件
This commit is contained in:
parent
4f481e4ec5
commit
fa5159fd53
13 changed files with 25 additions and 9 deletions
|
|
@ -16,6 +16,7 @@
|
|||
#include "resource.h"
|
||||
#include "App.h"
|
||||
#include "MainWindow.h"
|
||||
#include <ShlObj.h>
|
||||
|
||||
using namespace winrt;
|
||||
using namespace winrt::Magpie;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <wincodec.h>
|
||||
#include <parallel_hashmap/phmap.h>
|
||||
#include <AppxPackaging.h>
|
||||
#include <propsys.h>
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Windows::Graphics::Imaging;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
#include "StrHelper.h"
|
||||
#include "Win32Helper.h"
|
||||
#include <propkey.h>
|
||||
|
||||
#pragma comment(lib, "Taskschd.lib")
|
||||
#include <ShlObj.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include <ShlObj.h>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "Win32Helper.h"
|
||||
#include "StrHelper.h"
|
||||
#include "resource.h"
|
||||
#include <Shlobj.h>
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Windows::Graphics::Imaging;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
<Link>
|
||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalDependencies>Gdi32.lib;Dwmapi.lib;Shell32.lib;Ole32.lib;Imagehlp.lib;Comctl32.lib;Shlwapi.lib;Magnification.lib;bcp47mrm.lib;Shcore.lib;Uxtheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Gdi32.lib;Dwmapi.lib;Shell32.lib;Ole32.lib;Imagehlp.lib;Comctl32.lib;Shlwapi.lib;Magnification.lib;bcp47mrm.lib;Shcore.lib;Uxtheme.lib;Taskschd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>d3dcompiler_47.dll;Magnification.dll;Imagehlp.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "AppXReader.h"
|
||||
#include "CommonSharedConstants.h"
|
||||
#include "CandidateWindowItem.h"
|
||||
#include <dwmapi.h>
|
||||
|
||||
using namespace Magpie;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "Logger.h"
|
||||
#include "resource.h"
|
||||
#include "App.h"
|
||||
#include <CommCtrl.h>
|
||||
|
||||
using namespace winrt::Magpie::implementation;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "pch.h"
|
||||
#include "ThemeHelper.h"
|
||||
#include "Win32Helper.h"
|
||||
#include <dwmapi.h>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
|
|
@ -14,17 +15,24 @@ enum class PreferredAppMode {
|
|||
Max
|
||||
};
|
||||
|
||||
using fnSetPreferredAppMode = PreferredAppMode (WINAPI*)(PreferredAppMode appMode);
|
||||
using fnAllowDarkModeForWindow = bool (WINAPI*)(HWND hWnd, bool allow);
|
||||
using fnRefreshImmersiveColorPolicyState = void (WINAPI*)();
|
||||
using fnFlushMenuThemes = void (WINAPI*)();
|
||||
using fnSetPreferredAppMode = PreferredAppMode(WINAPI*)(PreferredAppMode appMode);
|
||||
using fnAllowDarkModeForWindow = bool(WINAPI*)(HWND hWnd, bool allow);
|
||||
using fnRefreshImmersiveColorPolicyState = void(WINAPI*)();
|
||||
using fnFlushMenuThemes = void(WINAPI*)();
|
||||
|
||||
static fnSetPreferredAppMode SetPreferredAppMode = nullptr;
|
||||
static fnAllowDarkModeForWindow AllowDarkModeForWindow = nullptr;
|
||||
static fnRefreshImmersiveColorPolicyState RefreshImmersiveColorPolicyState = nullptr;
|
||||
static fnFlushMenuThemes FlushMenuThemes = nullptr;
|
||||
|
||||
[[maybe_unused]]
|
||||
static bool IsInitialized() noexcept {
|
||||
return SetPreferredAppMode;
|
||||
}
|
||||
|
||||
void ThemeHelper::Initialize() noexcept {
|
||||
assert(!IsInitialized());
|
||||
|
||||
HMODULE hUxtheme = LoadLibraryEx(L"uxtheme.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
assert(hUxtheme);
|
||||
|
||||
|
|
@ -38,6 +46,8 @@ void ThemeHelper::Initialize() noexcept {
|
|||
}
|
||||
|
||||
void ThemeHelper::SetWindowTheme(HWND hWnd, bool darkBorder, bool darkMenu) noexcept {
|
||||
assert(IsInitialized());
|
||||
|
||||
SetPreferredAppMode(darkMenu ? PreferredAppMode::ForceDark : PreferredAppMode::ForceLight);
|
||||
AllowDarkModeForWindow(hWnd, darkMenu);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "LocalizationService.h"
|
||||
#include "XamlHelper.h"
|
||||
#include "App.h"
|
||||
#include <dwmapi.h>
|
||||
|
||||
using namespace ::Magpie;
|
||||
using namespace winrt::Magpie::implementation;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "Logger.h"
|
||||
#include "Win32Helper.h"
|
||||
#include "CommonSharedConstants.h"
|
||||
#include <Shlobj.h>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "Logger.h"
|
||||
#include "Event.h"
|
||||
#include "WindowBase.h"
|
||||
#include <dwmapi.h>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@
|
|||
#include <SDKDDKVer.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <dwmapi.h>
|
||||
#include <ShlObj.h>
|
||||
#include <shellapi.h>
|
||||
#include <Shlwapi.h>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue