This commit is contained in:
恍兮惚兮 2024-06-05 21:53:12 +08:00
parent 48a855f3ce
commit f7384a43aa
2 changed files with 26 additions and 5 deletions

View File

@ -316,10 +316,7 @@ _SetTheme.argtypes = HWND, c_bool, c_int
def SetTheme(hwnd, dark, backdrop):
try: # win7 x86 crash unknown why
_SetTheme(hwnd, dark, backdrop)
except:
pass
_SetTheme(hwnd, dark, backdrop)
showintab = utilsdll.showintab

View File

@ -1,6 +1,28 @@
#include "define.h"
// https://github.com/Blinue/Xaml-Islands-Cpp/blob/main/src/XamlIslandsCpp/XamlWindow.h
static uint32_t GetOSversion() noexcept
{
HMODULE hNtDll = GetModuleHandle(L"ntdll.dll");
if (!hNtDll)
{
return 0;
}
auto rtlGetVersion = (LONG(WINAPI *)(PRTL_OSVERSIONINFOW))GetProcAddress(hNtDll, "RtlGetVersion");
if (rtlGetVersion == nullptr)
{
// assert(false);
return 0;
}
RTL_OSVERSIONINFOW version{};
version.dwOSVersionInfoSize = sizeof(version);
rtlGetVersion(&version);
return version.dwMajorVersion;
}
static uint32_t GetOSBuild() noexcept
{
HMODULE hNtDll = GetModuleHandle(L"ntdll.dll");
@ -22,7 +44,6 @@ static uint32_t GetOSBuild() noexcept
return version.dwBuildNumber;
}
struct Win32Helper
{
struct OSVersion
@ -134,6 +155,9 @@ DECLARE void _SetTheme(
bool dark,
int backdrop)
{
// printf("%d %d\n",GetOSversion(),GetOSBuild());
if (GetOSversion() <= 6)//win7 x32 DwmSetWindowAttribute会崩直接禁了反正没用。不知道win8怎么样。
return;
// auto _isBackgroundSolidColor = backdrop == WindowBackdrop::SolidColor;
// if (Win32Helper::GetOSVersion().Is22H2OrNewer() &&
// _isBackgroundSolidColor != (backdrop == WindowBackdrop::SolidColor))