@@ -16,6 +16,7 @@ thread_local decltype(MenuHandler::g_sharedContext) MenuHandler::g_sharedContext
1616thread_local decltype (MenuHandler::g_sharedMenuInfo) MenuHandler::g_sharedMenuInfo{false , false };
1717const UINT MenuHandler::WM_MHDETACH{RegisterWindowMessageW (L" TranslucentFlyouts.MenuHandler.Detach" )};
1818const wstring_view MenuHandler::BackgroundBrushPropName{L" TranslucentFlyouts.MenuHandler.BackgroundBrush" };
19+ const wstring_view MenuHandler::BorderMarkerPropName{L" TranslucentFlyouts.MenuHandler.BorderMarker" };
1920
2021MenuHandler& 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" );
0 commit comments