Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.

Commit 155c48a

Browse files
committed
常规修复
1 parent f6bee65 commit 155c48a

File tree

5 files changed

+67
-12
lines changed

5 files changed

+67
-12
lines changed

TFMain/DXHelper.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "pch.h"
2+
#include "Utils.hpp"
23
#include "Hooking.hpp"
34
#include "DXHelper.hpp"
45

@@ -246,6 +247,8 @@ void LazyD3D::CreateDeviceResources()
246247
{
247248
try
248249
{
250+
auto CleanUp{Utils::RoInit()};
251+
249252
com_ptr<IDXGIDevice3> dxgiDevice{nullptr};
250253
com_ptr<ID3D11Device> d3dDevice{nullptr};
251254

TFMain/MenuAnimation.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,9 @@ namespace TranslucentFlyouts::MenuAnimation
211211
Attach();
212212

213213
Utils::CloakWindow(m_menuWindow, TRUE);
214-
SetCapture(m_menuWindow);
215214

216215
window = CreateWindowExW(
217-
WS_EX_NOREDIRECTIONBITMAP | WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_PALETTEWINDOW,
216+
WS_EX_NOREDIRECTIONBITMAP | WS_EX_LAYERED | WS_EX_TOPMOST | WS_EX_TOOLWINDOW,
218217
L"Static",
219218
L"PopupIn Animation",
220219
WS_POPUP,
@@ -315,6 +314,9 @@ namespace TranslucentFlyouts::MenuAnimation
315314
EffectHelper::EnableWindowDarkMode(window, info.useDarkMode);
316315

317316
menuHandler.ApplyEffect(L"Menu"sv, m_backdropWindow, info.useDarkMode);
317+
menuHandler.HandleRoundCorners(L"Menu"sv, m_backdropWindow);
318+
COLORREF color{DWMWA_COLOR_NONE};
319+
DwmSetWindowAttribute(m_backdropWindow, DWMWA_BORDER_COLOR, &color, sizeof(color));
318320
EffectHelper::EnableWindowDarkMode(m_backdropWindow, info.useDarkMode);
319321
}
320322
else

TFMain/MenuHandler.cpp

+59-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ thread_local decltype(MenuHandler::g_sharedContext) MenuHandler::g_sharedContext
1616
thread_local decltype(MenuHandler::g_sharedMenuInfo) MenuHandler::g_sharedMenuInfo{false, false};
1717
const UINT MenuHandler::WM_MHDETACH{RegisterWindowMessageW(L"TranslucentFlyouts.MenuHandler.Detach")};
1818
const wstring_view MenuHandler::BackgroundBrushPropName{L"TranslucentFlyouts.MenuHandler.BackgroundBrush"};
19+
const wstring_view MenuHandler::BorderMarkerPropName{L"TranslucentFlyouts.MenuHandler.BorderMarker"};
1920

2021
MenuHandler& MenuHandler::GetInstance()
2122
{
@@ -58,7 +59,18 @@ void MenuHandler::MenuOwnerMsgCallback(HWND hwnd, UINT message, WPARAM wParam, L
5859

5960
if (g_sharedMenuInfo.useUxTheme)
6061
{
61-
GetInstance().HandleSysBorderColors(L"Menu"sv, menuWindow, g_sharedMenuInfo.useDarkMode, g_sharedMenuInfo.borderColor);
62+
DWORD cornerType
63+
{
64+
RegHelper::GetDword(
65+
L"Menu",
66+
L"CornerType",
67+
3
68+
)
69+
};
70+
if (cornerType != 1 && SUCCEEDED(GetInstance().HandleSysBorderColors(L"Menu"sv, menuWindow, g_sharedMenuInfo.useDarkMode, g_sharedMenuInfo.borderColor)))
71+
{
72+
SetPropW(menuWindow, BorderMarkerPropName.data(), reinterpret_cast<HANDLE>(HANDLE_FLAG_INHERIT));
73+
}
6274
GetInstance().HandleRoundCorners(L"Menu"sv, menuWindow);
6375
}
6476
}
@@ -420,7 +432,18 @@ LRESULT CALLBACK MenuHandler::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
420432
result = DefSubclassProc(hWnd, uMsg, wParam, lParam);
421433
g_sharedContext.menuDC = nullptr;
422434

423-
GetInstance().HandleSysBorderColors(L"Menu"sv, hWnd, g_sharedMenuInfo.useDarkMode, g_sharedMenuInfo.borderColor);
435+
DWORD cornerType
436+
{
437+
RegHelper::GetDword(
438+
L"Menu",
439+
L"CornerType",
440+
3
441+
)
442+
};
443+
if (cornerType != 1 && SUCCEEDED(GetInstance().HandleSysBorderColors(L"Menu"sv, hWnd, g_sharedMenuInfo.useDarkMode, g_sharedMenuInfo.borderColor)))
444+
{
445+
SetPropW(hWnd, BorderMarkerPropName.data(), reinterpret_cast<HANDLE>(HANDLE_FLAG_INHERIT));
446+
}
424447
GetInstance().HandleRoundCorners(L"Menu"sv, hWnd);
425448
}
426449

@@ -500,7 +523,18 @@ LRESULT CALLBACK MenuHandler::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
500523
else
501524
{
502525
menuHandler.ApplyEffect(L"Menu"sv, hWnd, info.useDarkMode);
503-
GetInstance().HandleSysBorderColors(L"Menu"sv, hWnd, info.useDarkMode, info.borderColor);
526+
DWORD cornerType
527+
{
528+
RegHelper::GetDword(
529+
L"Menu",
530+
L"CornerType",
531+
3
532+
)
533+
};
534+
if (cornerType != 1 && SUCCEEDED(GetInstance().HandleSysBorderColors(L"Menu"sv, hWnd, info.useDarkMode, info.borderColor)))
535+
{
536+
SetPropW(hWnd, BorderMarkerPropName.data(), reinterpret_cast<HANDLE>(HANDLE_FLAG_INHERIT));
537+
}
504538
GetInstance().HandleRoundCorners(L"Menu"sv, hWnd);
505539

506540
try
@@ -618,7 +652,14 @@ LRESULT CALLBACK MenuHandler::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
618652
GetWindowRect(hWnd, &paintRect);
619653
OffsetRect(&paintRect, -paintRect.left, -paintRect.top);
620654

621-
menuHandler.HandlePopupMenuNCBorderColors(hdc.get(), g_sharedMenuInfo.useDarkMode, paintRect);
655+
if (!GetPropW(hWnd, BorderMarkerPropName.data()))
656+
{
657+
menuHandler.HandlePopupMenuNCBorderColors(hdc.get(), g_sharedMenuInfo.useDarkMode, paintRect);
658+
}
659+
else
660+
{
661+
LOG_LAST_ERROR_IF(!FrameRect(hdc.get(), &paintRect, GetStockBrush(BLACK_BRUSH)));
662+
}
622663
}
623664
}
624665

@@ -642,21 +683,33 @@ LRESULT CALLBACK MenuHandler::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
642683
GetWindowRect(hWnd, &paintRect);
643684
OffsetRect(&paintRect, -paintRect.left, -paintRect.top);
644685

645-
menuHandler.HandlePopupMenuNCBorderColors(hdc.get(), g_sharedMenuInfo.useDarkMode, paintRect);
686+
if (!GetPropW(hWnd, BorderMarkerPropName.data()))
687+
{
688+
menuHandler.HandlePopupMenuNCBorderColors(hdc.get(), g_sharedMenuInfo.useDarkMode, paintRect);
689+
}
690+
else
691+
{
692+
LOG_LAST_ERROR_IF(!FrameRect(hdc.get(), &paintRect, GetStockBrush(BLACK_BRUSH)));
693+
}
646694
}
647695
}
648696

649697
if (uMsg == WM_NCDESTROY || uMsg == WM_MHDETACH)
650698
{
651699
auto brush{reinterpret_cast<HBRUSH>(GetPropW(hWnd, BackgroundBrushPropName.data()))};
652-
if (brush)
700+
if (GetLastError() == ERROR_SUCCESS)
653701
{
654702
MENUINFO mi{.cbSize{sizeof(mi)}, .fMask{MIM_BACKGROUND}, .hbrBack{brush}};
655703
LOG_HR_IF(E_FAIL, !SetMenuInfo(reinterpret_cast<HMENU>(DefSubclassProc(hWnd, MN_GETHMENU, 0, 0)), &mi));
656704

657705
RemovePropW(hWnd, BackgroundBrushPropName.data());
658706
}
659707

708+
if (GetPropW(hWnd, BorderMarkerPropName.data()))
709+
{
710+
RemovePropW(hWnd, BorderMarkerPropName.data());
711+
}
712+
660713
if (uMsg == WM_MHDETACH)
661714
{
662715
RemovePropW(hWnd, L"IsZachMenuDWMAttributeSet");

TFMain/MenuHandler.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ namespace TranslucentFlyouts
197197

198198
static const UINT WM_MHDETACH;
199199
static const std::wstring_view BackgroundBrushPropName;
200+
static const std::wstring_view BorderMarkerPropName;
200201

201202
bool m_internalError{false};
202203
std::list<HWND> m_hookedWindowList{};

TFMain/TFMain.vcxproj

-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
<GenerateDebugInformation>true</GenerateDebugInformation>
121121
<EnableUAC>false</EnableUAC>
122122
<ModuleDefinitionFile>GlobalFunctions.def</ModuleDefinitionFile>
123-
<DelayLoadDLLs>dcomp.dll;d2d1.dll;d3d11.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
124123
</Link>
125124
</ItemDefinitionGroup>
126125
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -151,7 +150,6 @@
151150
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
152151
<EnableUAC>false</EnableUAC>
153152
<ModuleDefinitionFile>GlobalFunctions.def</ModuleDefinitionFile>
154-
<DelayLoadDLLs>dcomp.dll;d2d1.dll;d3d11.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
155153
</Link>
156154
</ItemDefinitionGroup>
157155
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -170,7 +168,6 @@
170168
<GenerateDebugInformation>true</GenerateDebugInformation>
171169
<EnableUAC>false</EnableUAC>
172170
<ModuleDefinitionFile>GlobalFunctions.def</ModuleDefinitionFile>
173-
<DelayLoadDLLs>dcomp.dll;d2d1.dll;d3d11.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
174171
</Link>
175172
</ItemDefinitionGroup>
176173
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -202,7 +199,6 @@
202199
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
203200
<EnableUAC>false</EnableUAC>
204201
<ModuleDefinitionFile>GlobalFunctions.def</ModuleDefinitionFile>
205-
<DelayLoadDLLs>dcomp.dll;d2d1.dll;d3d11.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
206202
</Link>
207203
</ItemDefinitionGroup>
208204
<ItemGroup>

0 commit comments

Comments
 (0)