Skip to content

Commit 1e268e2

Browse files
committed
2 parents 1b0927f + 90184ac commit 1e268e2

File tree

2 files changed

+62
-27
lines changed

2 files changed

+62
-27
lines changed

DWMBlurGlassExt/Common/DWMStruct.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,15 @@ namespace MDWMBlurGlassExt::DWM
633633

634634
CText* CTopLevelWindow::GetCText()
635635
{
636-
const auto text = *((CText**)this + 65);
636+
CText* text{nullptr};
637+
if (os::buildNumber < 22000)
638+
{
639+
text = *((CText**)this + 65);
640+
}
641+
else
642+
{
643+
text = *((CText**)this + 67);
644+
}
637645
return text;
638646
}
639647

@@ -838,7 +846,15 @@ namespace MDWMBlurGlassExt::DWM
838846

839847
LPCWSTR CText::GetText()
840848
{
841-
const wchar_t* text = (wchar_t*)*((DWORD64*)this + 36);
849+
LPCWSTR text{nullptr};
850+
if (os::buildNumber < 22000)
851+
{
852+
text = (wchar_t*)*((DWORD64*)this + 36);
853+
}
854+
else
855+
{
856+
text = (wchar_t*)*((DWORD64*)this + 37);
857+
}
842858
return text;
843859
}
844860

DWMBlurGlassExt/Section/TitleTextTweaker.cpp

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,25 @@ namespace MDWMBlurGlassExt::TitleTextTweaker
5656
WriteMemory(g_pCreateBitmapFromHBITMAP, [&] { *(PVOID*)g_pCreateBitmapFromHBITMAP = MyCreateBitmapFromHBITMAP; });
5757
}
5858

59-
if (os::buildNumber < 22000)
59+
if (os::buildNumber < 22621)
6060
{
6161
g_funCTopLevelWindow_UpdateWindowVisuals.Attach();
6262
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<1, true>();
6363
}
64-
else if (os::buildNumber >= 22000)
64+
else if (os::buildNumber >= 22621)
6565
{
6666
g_funCTopLevelWindow_UpdateText.Attach();
6767
}
6868

6969
HMODULE udwmModule = GetModuleHandleW(L"udwm.dll");
70-
if (os::buildNumber <= 22621)
70+
if (os::buildNumber < 22621)
7171
{
7272
HMODULE hModule = GetModuleHandleW(L"user32.dll");
7373
g_funFillRect = (decltype(g_funFillRect))GetProcAddress(hModule, "FillRect");
7474
g_funDrawTextW = (decltype(g_funDrawTextW))GetProcAddress(hModule, "DrawTextW");
7575
WriteIAT(udwmModule, "User32.dll", { { "FillRect", MyFillRect }, { "DrawTextW", MyDrawTextW } });
7676
}
77-
if (os::buildNumber < 22000)
77+
if (os::buildNumber < 22621)
7878
{
7979
HMODULE hModule = GetModuleHandleW(L"gdi32.dll");
8080
g_funCreateBitmap = (decltype(g_funCreateBitmap))GetProcAddress(hModule, "CreateBitmap");
@@ -84,11 +84,11 @@ namespace MDWMBlurGlassExt::TitleTextTweaker
8484

8585
void Detach()
8686
{
87-
if (os::buildNumber >= 22000)
87+
if (os::buildNumber >= 22621)
8888
{
8989
g_funCTopLevelWindow_UpdateText.Detach();
9090
}
91-
else if (os::buildNumber < 22000)
91+
else if (os::buildNumber < 22621)
9292
{
9393
g_funCTopLevelWindow_UpdateWindowVisuals.Detach();
9494
g_CTopLevelWindow_ValidateVisual_HookDispatcher.enable_hook_routine<1, false>();
@@ -98,11 +98,11 @@ namespace MDWMBlurGlassExt::TitleTextTweaker
9898
WriteMemory(g_pCreateBitmapFromHBITMAP, [&] {*(PVOID*)g_pCreateBitmapFromHBITMAP = g_funCreateBitmapFromHBITMAP; });
9999

100100
HMODULE udwmModule = GetModuleHandleW(L"udwm.dll");
101-
if (os::buildNumber <= 22621)
101+
if (os::buildNumber < 22621)
102102
{
103103
WriteIAT(udwmModule, "User32.dll", { { "DrawTextW", g_funDrawTextW } , { "FillRect", g_funFillRect } });
104104
}
105-
if (os::buildNumber < 22000)
105+
if (os::buildNumber < 22621)
106106
WriteIAT(udwmModule, "gdi32.dll", { { "CreateBitmap", g_funCreateBitmap } });
107107
}
108108

@@ -118,15 +118,18 @@ namespace MDWMBlurGlassExt::TitleTextTweaker
118118

119119
if ((format & DT_CALCRECT) || (format & DT_INTERNAL) || (format & DT_NOCLIP))
120120
{
121-
//兼容第三方主题绘制发光字需要预留一些区域
122-
if (format & DT_CALCRECT)
121+
if (os::buildNumber < 22621)
123122
{
124-
auto ret = g_funDrawTextW(hdc, lpchText, cchText, lprc, format);
125-
lprc->right += 30;
126-
lprc->bottom += 20;
127-
lprc->top = 0;
128-
lprc->left = -10;
129-
return ret + 20;
123+
//兼容第三方主题绘制发光字需要预留一些区域
124+
if (format & DT_CALCRECT)
125+
{
126+
auto ret = g_funDrawTextW(hdc, lpchText, cchText, lprc, format);
127+
lprc->right += 30;
128+
lprc->bottom += 20;
129+
lprc->top = 0;
130+
lprc->left = -10;
131+
return ret + 20;
132+
}
130133
}
131134
return g_funDrawTextW(hdc, lpchText, cchText, lprc, format);
132135
}
@@ -160,8 +163,11 @@ namespace MDWMBlurGlassExt::TitleTextTweaker
160163
return g_funDrawTextW(hdc, lpchText, cchText, lprc, format);
161164

162165
RECT offset = *lprc;
163-
offset.left += 20;
164-
offset.top += 10;
166+
if (os::buildNumber < 22621)
167+
{
168+
offset.left += 20;
169+
offset.top += 10;
170+
}
165171
if (FAILED(DrawThemeTextEx(hTheme, hdc, 0, 0, lpchText, cchText, DT_LEFT | DT_TOP, &offset, &Options)))
166172
return g_funDrawTextW(hdc, lpchText, cchText, lprc, format);
167173
return 1;
@@ -184,12 +190,25 @@ namespace MDWMBlurGlassExt::TitleTextTweaker
184190

185191
HRESULT CTopLevelWindow_UpdateWindowVisuals(CTopLevelWindow* This)
186192
{
187-
auto frame = CTopLevelWindow::s_ChooseWindowFrameFromStyle
188-
(
189-
(char)*((DWORD*)This + 148),
190-
false,
191-
(char)(*(BYTE*)(*((ULONG64*)This + 91) + 611) & 0x20) != 0
192-
);
193+
CTopLevelWindow::WindowFrame* frame{nullptr};
194+
if (os::buildNumber < 22000)
195+
{
196+
frame = CTopLevelWindow::s_ChooseWindowFrameFromStyle
197+
(
198+
(char)*((DWORD*)This + 148),
199+
false,
200+
(char)(*(BYTE*)(*((ULONG64*)This + 91) + 611) & 0x20) != 0
201+
);
202+
}
203+
else
204+
{
205+
frame = CTopLevelWindow::s_ChooseWindowFrameFromStyle
206+
(
207+
(char)*((DWORD*)This + 152),
208+
false,
209+
(char)(*(BYTE*)(*((ULONG64*)This + 94) + 667) & 0x20) != 0
210+
);
211+
}
193212

194213
//对于Ribbon或扩展到NC区域的窗口 我们无法处理标题文本颜色 需要过滤掉 它应该由应用程序处理
195214
if (frame && (*((BYTE*)This + 592) & 8) != 0)
@@ -239,7 +258,7 @@ namespace MDWMBlurGlassExt::TitleTextTweaker
239258

240259
g_window = hWnd;
241260

242-
if (os::buildNumber < 22000 && This->HasNonClientBackground())
261+
if (os::buildNumber < 22621 && This->HasNonClientBackground())
243262
{
244263
//DrawText处给发光字预留了空间 需要刷新文本布局
245264
if (CText* textThis = This->GetCText())

0 commit comments

Comments
 (0)