@@ -16,6 +16,7 @@ thread_local decltype(MenuHandler::g_sharedContext) MenuHandler::g_sharedContext
16
16
thread_local decltype (MenuHandler::g_sharedMenuInfo) MenuHandler::g_sharedMenuInfo{false , false };
17
17
const UINT MenuHandler::WM_MHDETACH{RegisterWindowMessageW (L" TranslucentFlyouts.MenuHandler.Detach" )};
18
18
const wstring_view MenuHandler::BackgroundBrushPropName{L" TranslucentFlyouts.MenuHandler.BackgroundBrush" };
19
+ const wstring_view MenuHandler::BorderMarkerPropName{L" TranslucentFlyouts.MenuHandler.BorderMarker" };
19
20
20
21
MenuHandler& MenuHandler::GetInstance ()
21
22
{
@@ -58,7 +59,18 @@ void MenuHandler::MenuOwnerMsgCallback(HWND hwnd, UINT message, WPARAM wParam, L
58
59
59
60
if (g_sharedMenuInfo.useUxTheme )
60
61
{
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
+ }
62
74
GetInstance ().HandleRoundCorners (L" Menu" sv, menuWindow);
63
75
}
64
76
}
@@ -420,7 +432,18 @@ LRESULT CALLBACK MenuHandler::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
420
432
result = DefSubclassProc (hWnd, uMsg, wParam, lParam);
421
433
g_sharedContext.menuDC = nullptr ;
422
434
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
+ }
424
447
GetInstance ().HandleRoundCorners (L" Menu" sv, hWnd);
425
448
}
426
449
@@ -500,7 +523,18 @@ LRESULT CALLBACK MenuHandler::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
500
523
else
501
524
{
502
525
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
+ }
504
538
GetInstance ().HandleRoundCorners (L" Menu" sv, hWnd);
505
539
506
540
try
@@ -618,7 +652,14 @@ LRESULT CALLBACK MenuHandler::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
618
652
GetWindowRect (hWnd, &paintRect);
619
653
OffsetRect (&paintRect, -paintRect.left , -paintRect.top );
620
654
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
+ }
622
663
}
623
664
}
624
665
@@ -642,21 +683,33 @@ LRESULT CALLBACK MenuHandler::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
642
683
GetWindowRect (hWnd, &paintRect);
643
684
OffsetRect (&paintRect, -paintRect.left , -paintRect.top );
644
685
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
+ }
646
694
}
647
695
}
648
696
649
697
if (uMsg == WM_NCDESTROY || uMsg == WM_MHDETACH)
650
698
{
651
699
auto brush{reinterpret_cast <HBRUSH>(GetPropW (hWnd, BackgroundBrushPropName.data ()))};
652
- if (brush )
700
+ if (GetLastError () == ERROR_SUCCESS )
653
701
{
654
702
MENUINFO mi{.cbSize {sizeof (mi)}, .fMask {MIM_BACKGROUND}, .hbrBack {brush}};
655
703
LOG_HR_IF (E_FAIL, !SetMenuInfo (reinterpret_cast <HMENU>(DefSubclassProc (hWnd, MN_GETHMENU, 0 , 0 )), &mi));
656
704
657
705
RemovePropW (hWnd, BackgroundBrushPropName.data ());
658
706
}
659
707
708
+ if (GetPropW (hWnd, BorderMarkerPropName.data ()))
709
+ {
710
+ RemovePropW (hWnd, BorderMarkerPropName.data ());
711
+ }
712
+
660
713
if (uMsg == WM_MHDETACH)
661
714
{
662
715
RemovePropW (hWnd, L" IsZachMenuDWMAttributeSet" );
0 commit comments