File tree 1 file changed +20
-1
lines changed
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -4579,7 +4579,11 @@ protected override void WndProc(ref Message m)
4579
4579
SnapFocus ( ( HWND ) ( nint ) m . WParamInternal ) ;
4580
4580
4581
4581
// For fix https://github.com/dotnet/winforms/issues/12916
4582
- ToolStripManager . ModalMenuFilter . SetActiveToolStrip ( this ) ;
4582
+ // Narrow down the range, because ToolStripDropDown is ToolStrip too. we only need to set outer ToolStrip active.
4583
+ if ( IsOuterToolStrip ( this ) )
4584
+ {
4585
+ ToolStripManager . ModalMenuFilter . SetActiveToolStrip ( this ) ;
4586
+ }
4583
4587
}
4584
4588
4585
4589
if ( ! AllowClickThrough && m . MsgInternal == PInvokeCore . WM_MOUSEACTIVATE )
@@ -4646,6 +4650,21 @@ protected override void WndProc(ref Message m)
4646
4650
// WM_DESTROY.
4647
4651
_dropDownOwnerWindow ? . DestroyHandle ( ) ;
4648
4652
}
4653
+
4654
+ static bool IsOuterToolStrip ( ToolStrip toolStrip )
4655
+ {
4656
+ static ToolStrip getParentToolStrip ( ToolStrip toolStrip )
4657
+ {
4658
+ if ( toolStrip . Parent is ToolStrip parent )
4659
+ {
4660
+ return getParentToolStrip ( parent ) ;
4661
+ }
4662
+
4663
+ return toolStrip ;
4664
+ }
4665
+
4666
+ return toolStrip == getParentToolStrip ( toolStrip ) ;
4667
+ }
4649
4668
}
4650
4669
4651
4670
// Overridden to return Items instead of Controls.
You can’t perform that action at this time.
0 commit comments