Skip to content

Commit

Permalink
Update Helper.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Maplespe authored Aug 27, 2022
1 parent 0d19213 commit a054352
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ExplorerBlurMica/Helper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* WinAPI助手
* WinAPI助手
*
* Author: Maple
* date: 2021-7-13 Create
Expand Down Expand Up @@ -100,10 +100,10 @@ const pSetWindowCompositionAttribute SetWindowCompositionAttribute

void StartAero(HWND hwnd, bool Acrylic, COLORREF color, bool blend)
{
//win10未公开API https://hack.jp/?p=245
//win10未公开API https://hack.jp/?p=245
if (SetWindowCompositionAttribute)
{
/*亚克力效果参数
/*亚克力效果参数
https://github.com/Hxmg/Win32AcrylicBlur
*/
ACCENTPOLICY policy = { Acrylic == false ? 3 : 4, 0, 0, 0 };
Expand Down Expand Up @@ -187,7 +187,7 @@ bool CheckCaller(LPCWSTR caller, void* address)
return CheckCaller(GetModuleHandleW(caller), address);
}

UINT CalcRibbonHeightForDPI(HWND hWnd, UINT src, bool normal)
UINT CalcRibbonHeightForDPI(HWND hWnd, UINT src, bool normal, bool offsets)
{
static auto GetWindowDPI = [](HWND hwnd) -> UINT
{
Expand Down Expand Up @@ -216,13 +216,19 @@ UINT CalcRibbonHeightForDPI(HWND hWnd, UINT src, bool normal)
if (scale != 1.f) {
if (!normal) {
float offset = round(1.5f * scale);
float height = round((float)src * scale) - offset;
float height = round((float)src * scale);
if (offsets)
height -= offset;
else if (scale == 2.f)
height += 2;
else if(scale < 1.7)
height -= 1;

return (UINT)height;
}
else
{
return UINT(scale * (float)src);
return (UINT)round(scale * (float)src);
}
}
return src;
Expand Down Expand Up @@ -257,7 +263,7 @@ std::wstring RegGetSZ(HKEY hKey, LPCWSTR SubKey, LPCWSTR KeyName)

LSTATUS status = RegOpenKeyExW(hKey, SubKey, 0, KEY_READ, &tkey);

//以备份还原级别权限再重试
//以备份还原级别权限再重试
if (status != ERROR_SUCCESS)
{
EnablePriviledge(SE_BACKUP_NAME);
Expand Down Expand Up @@ -371,4 +377,4 @@ void RefreshWin10BlurFrame(bool blurType)
setreg(L"0");
}
}
}
}

0 comments on commit a054352

Please sign in to comment.