mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
fix: 修复闪退错误
This commit is contained in:
parent
0a83905d1b
commit
bc2a201fa6
1 changed files with 29 additions and 29 deletions
|
|
@ -74,26 +74,6 @@ bool App::Run(
|
|||
|
||||
SetErrorMsg(ErrorMessages::GENERIC);
|
||||
|
||||
// 禁用窗口圆角
|
||||
bool roundCornerDisabled = false;
|
||||
if (IsDisableRoundCorner() && _frameSource->HasRoundCornerInWin11()) {
|
||||
const auto& version = Utils::GetOSVersion();
|
||||
bool isWin11 = Utils::CompareVersion(
|
||||
version.dwMajorVersion, version.dwMinorVersion,
|
||||
version.dwBuildNumber, 10, 0, 22000) >= 0;
|
||||
|
||||
if (isWin11) {
|
||||
INT attr = DWMWCP_DONOTROUND;
|
||||
HRESULT hr = DwmSetWindowAttribute(hwndSrc, DWMWA_WINDOW_CORNER_PREFERENCE, &attr, sizeof(attr));
|
||||
if (FAILED(hr)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, "禁用窗口圆角失败");
|
||||
} else {
|
||||
SPDLOG_LOGGER_INFO(logger, "已禁用窗口圆角");
|
||||
roundCornerDisabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 禁用窗口大小调整
|
||||
bool windowResizingDisabled = false;
|
||||
if (IsDisableWindowResizing()) {
|
||||
|
|
@ -173,8 +153,39 @@ bool App::Run(
|
|||
return false;
|
||||
}
|
||||
|
||||
// 禁用窗口圆角
|
||||
bool roundCornerDisabled = false;
|
||||
if (IsDisableRoundCorner() && _frameSource->HasRoundCornerInWin11()) {
|
||||
const auto& version = Utils::GetOSVersion();
|
||||
bool isWin11 = Utils::CompareVersion(
|
||||
version.dwMajorVersion, version.dwMinorVersion,
|
||||
version.dwBuildNumber, 10, 0, 22000) >= 0;
|
||||
|
||||
if (isWin11) {
|
||||
INT attr = DWMWCP_DONOTROUND;
|
||||
HRESULT hr = DwmSetWindowAttribute(hwndSrc, DWMWA_WINDOW_CORNER_PREFERENCE, &attr, sizeof(attr));
|
||||
if (FAILED(hr)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, "禁用窗口圆角失败");
|
||||
} else {
|
||||
SPDLOG_LOGGER_INFO(logger, "已禁用窗口圆角");
|
||||
roundCornerDisabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_Run();
|
||||
|
||||
// 还原窗口圆角
|
||||
if (roundCornerDisabled) {
|
||||
INT attr = DWMWCP_DEFAULT;
|
||||
HRESULT hr = DwmSetWindowAttribute(hwndSrc, DWMWA_WINDOW_CORNER_PREFERENCE, &attr, sizeof(attr));
|
||||
if (FAILED(hr)) {
|
||||
SPDLOG_LOGGER_INFO(logger, "取消禁用窗口圆角失败");
|
||||
} else {
|
||||
SPDLOG_LOGGER_INFO(logger, "已取消禁用窗口圆角");
|
||||
}
|
||||
}
|
||||
|
||||
// 还原窗口大小调整
|
||||
if (windowResizingDisabled) {
|
||||
LONG_PTR style = GetWindowLongPtr(hwndSrc, GWL_STYLE);
|
||||
|
|
@ -187,17 +198,6 @@ bool App::Run(
|
|||
}
|
||||
}
|
||||
|
||||
// 还原窗口圆角
|
||||
if (roundCornerDisabled) {
|
||||
INT attr = DWMWCP_DEFAULT;
|
||||
HRESULT hr = DwmSetWindowAttribute(hwndSrc, DWMWA_WINDOW_CORNER_PREFERENCE, &attr, sizeof(attr));
|
||||
if (FAILED(hr)) {
|
||||
SPDLOG_LOGGER_INFO(logger, "取消禁用窗口圆角失败");
|
||||
} else {
|
||||
SPDLOG_LOGGER_INFO(logger, "已取消禁用窗口圆角");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue