修复win11设置效果崩溃的错误

This commit is contained in:
jeffrey0326
2024-08-21 22:07:20 +08:00
parent b6c7afc744
commit 76f40a6265
2 changed files with 284 additions and 0 deletions

View File

@ -136,6 +136,13 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
if (!isWin11OrGreater()) {
return false;
}
if(module && !pDwmSetWindowAttribute){
pDwmSetWindowAttribute = reinterpret_cast<DwmSetWindowAttributeFunc>(
GetProcAddress(module, "DwmSetWindowAttribute"));
if (!pDwmSetWindowAttribute) {
return false;
}
}
if (enable) {
pDwmExtendFrameIntoClientArea(hwnd, &extendedMargins);
if (isWin1122H2OrGreater()) {
@ -163,6 +170,13 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
if (!isWin1122H2OrGreater()) {
return false;
}
if(module && !pDwmSetWindowAttribute){
pDwmSetWindowAttribute = reinterpret_cast<DwmSetWindowAttributeFunc>(
GetProcAddress(module, "DwmSetWindowAttribute"));
if (!pDwmSetWindowAttribute) {
return false;
}
}
if (enable) {
pDwmExtendFrameIntoClientArea(hwnd, &extendedMargins);
const DWORD backdropType = _DWMSBT_TABBEDWINDOW;
@ -180,6 +194,13 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
if (!isWin11OrGreater()) {
return false;
}
if(module && !pDwmSetWindowAttribute){
pDwmSetWindowAttribute = reinterpret_cast<DwmSetWindowAttributeFunc>(
GetProcAddress(module, "DwmSetWindowAttribute"));
if (!pDwmSetWindowAttribute) {
return false;
}
}
if (enable) {
MARGINS margins{-1, -1, -1, -1};
pDwmExtendFrameIntoClientArea(hwnd, &margins);