mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
sys
This commit is contained in:
parent
5a719d16e5
commit
ef5ebbd7fe
@ -2,7 +2,6 @@
|
|||||||
#define DECLARE extern "C" __declspec(dllexport)
|
#define DECLARE extern "C" __declspec(dllexport)
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
__declspec(dllexport) bool _SetTheme(HWND _hWnd, bool dark, int backdrop);
|
|
||||||
|
|
||||||
__declspec(dllexport) HANDLE startdarklistener();
|
__declspec(dllexport) HANDLE startdarklistener();
|
||||||
__declspec(dllexport) bool queryversion(const wchar_t *exe, WORD *_1, WORD *_2, WORD *_3, WORD *_4);
|
__declspec(dllexport) bool queryversion(const wchar_t *exe, WORD *_1, WORD *_2, WORD *_3, WORD *_4);
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
#include "define.h"
|
#include "define.h"
|
||||||
// https://github.com/Blinue/Xaml-Islands-Cpp/blob/main/src/XamlIslandsCpp/XamlWindow.h
|
// https://github.com/Blinue/Xaml-Islands-Cpp/blob/main/src/XamlIslandsCpp/XamlWindow.h
|
||||||
|
|
||||||
enum WindowBackdrop : int32_t
|
|
||||||
{
|
|
||||||
SolidColor = 0,
|
|
||||||
Acrylic = 1,
|
|
||||||
Mica = 2,
|
|
||||||
MicaAlt = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint32_t GetOSBuild() noexcept
|
static uint32_t GetOSBuild() noexcept
|
||||||
{
|
{
|
||||||
HMODULE hNtDll = GetModuleHandle(L"ntdll.dll");
|
HMODULE hNtDll = GetModuleHandle(L"ntdll.dll");
|
||||||
@ -137,40 +129,41 @@ static void SetWindowTheme(HWND hWnd, bool darkBorder, bool darkMenu) noexcept
|
|||||||
RefreshImmersiveColorPolicyState();
|
RefreshImmersiveColorPolicyState();
|
||||||
FlushMenuThemes();
|
FlushMenuThemes();
|
||||||
}
|
}
|
||||||
bool _SetTheme(
|
DECLARE void _SetTheme(
|
||||||
HWND _hWnd,
|
HWND _hWnd,
|
||||||
bool dark,
|
bool dark,
|
||||||
int backdrop)
|
int backdrop)
|
||||||
{
|
{
|
||||||
auto _isBackgroundSolidColor = backdrop == WindowBackdrop::SolidColor;
|
// auto _isBackgroundSolidColor = backdrop == WindowBackdrop::SolidColor;
|
||||||
if (Win32Helper::GetOSVersion().Is22H2OrNewer() &&
|
// if (Win32Helper::GetOSVersion().Is22H2OrNewer() &&
|
||||||
_isBackgroundSolidColor != (backdrop == WindowBackdrop::SolidColor))
|
// _isBackgroundSolidColor != (backdrop == WindowBackdrop::SolidColor))
|
||||||
{
|
// {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Win10 中即使在亮色主题下我们也使用暗色边框,这也是 UWP 窗口的行为
|
// Win10 中即使在亮色主题下我们也使用暗色边框,这也是 UWP 窗口的行为
|
||||||
SetWindowTheme(
|
SetWindowTheme(
|
||||||
_hWnd,
|
_hWnd,
|
||||||
Win32Helper::GetOSVersion().IsWin11() ? dark : true,
|
Win32Helper::GetOSVersion().IsWin11() ? dark : true,
|
||||||
dark);
|
dark);
|
||||||
|
|
||||||
if (!Win32Helper::GetOSVersion().Is22H2OrNewer())
|
// if (!Win32Helper::GetOSVersion().Is22H2OrNewer())
|
||||||
{
|
// {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// https://learn.microsoft.com/zh-cn/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type
|
||||||
// 设置背景
|
// 设置背景
|
||||||
static const DWM_SYSTEMBACKDROP_TYPE BACKDROP_MAP[] = {
|
static const DWM_SYSTEMBACKDROP_TYPE BACKDROP_MAP[] = {
|
||||||
DWMSBT_AUTO, DWMSBT_TRANSIENTWINDOW, DWMSBT_MAINWINDOW, DWMSBT_TABBEDWINDOW};
|
DWMSBT_AUTO, DWMSBT_TRANSIENTWINDOW, DWMSBT_MAINWINDOW, DWMSBT_TABBEDWINDOW};
|
||||||
DWM_SYSTEMBACKDROP_TYPE value = BACKDROP_MAP[(int)backdrop];
|
DWM_SYSTEMBACKDROP_TYPE value = BACKDROP_MAP[(int)backdrop];
|
||||||
|
|
||||||
MARGINS mar{-1,-1,-1,-1};
|
|
||||||
DwmExtendFrameIntoClientArea(_hWnd,&mar);
|
|
||||||
|
|
||||||
|
MARGINS mar{-1, -1, -1, -1};
|
||||||
|
DwmExtendFrameIntoClientArea(_hWnd, &mar);
|
||||||
|
|
||||||
DwmSetWindowAttribute(_hWnd, DWMWA_SYSTEMBACKDROP_TYPE, &value, sizeof(value));
|
DwmSetWindowAttribute(_hWnd, DWMWA_SYSTEMBACKDROP_TYPE, &value, sizeof(value));
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE bool isDark()
|
DECLARE bool isDark()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user