Skip to content

Commit 7f3332b

Browse files
committed
Update DisplayRectangle
1 parent a7fcf68 commit 7f3332b

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/StatusStrip.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,28 +317,44 @@ public override Rectangle DisplayRectangle
317317
{
318318
get
319319
{
320-
Rectangle rectangle = base.DisplayRectangle;
320+
Rectangle rect = base.DisplayRectangle;
321321

322322
if (!SizingGrip)
323323
{
324-
return rectangle;
324+
return rect;
325325
}
326326

327327
Rectangle grip = SizeGripBounds;
328-
int remainingWidth = rectangle.Width - grip.Width;
329-
if (grip.IsEmpty || remainingWidth <= 0)
328+
329+
if (grip.IsEmpty)
330330
{
331-
return rectangle;
331+
return rect;
332332
}
333333

334-
if (RightToLeft == RightToLeft.Yes)
334+
if (Dock is DockStyle.Bottom or DockStyle.Top or DockStyle.Fill)
335335
{
336-
rectangle.X += grip.Width;
337-
}
336+
int remainingWidth = rect.Width - grip.Width;
337+
if (remainingWidth > 0)
338+
{
339+
if (RightToLeft == RightToLeft.Yes)
340+
{
341+
rect.X += grip.Width;
342+
}
338343

339-
rectangle.Width = remainingWidth;
344+
rect.Width = remainingWidth;
345+
}
346+
}
347+
else if (Dock is DockStyle.Left or DockStyle.Right)
348+
{
349+
int remainingHeight = rect.Height - grip.Height;
350+
if (remainingHeight > 0)
351+
{
352+
rect.Y += grip.Height;
353+
rect.Height = remainingHeight;
354+
}
355+
}
340356

341-
return rectangle;
357+
return rect;
342358
}
343359
}
344360

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,11 @@ public override Rectangle DisplayRectangle
728728
{
729729
Rectangle rect = base.DisplayRectangle;
730730

731+
if (this is StatusStrip)
732+
{
733+
return rect;
734+
}
735+
731736
if ((LayoutEngine is ToolStripSplitStackLayout) && (GripStyle == ToolStripGripStyle.Visible))
732737
{
733738
if (Orientation == Orientation.Horizontal)
@@ -3940,7 +3945,7 @@ internal override void ReleaseUiaProvider(HWND handle)
39403945
/// <param name="items">contains ToolStrip or ToolStripDropDown items to disconnect</param>
39413946
internal virtual void ReleaseToolStripItemsProviders(ToolStripItemCollection items)
39423947
{
3943-
ToolStripItem[] itemsArray = [..items.Cast<ToolStripItem>()];
3948+
ToolStripItem[] itemsArray = [.. items.Cast<ToolStripItem>()];
39443949
foreach (ToolStripItem toolStripItem in itemsArray)
39453950
{
39463951
if (toolStripItem is ToolStripDropDownItem dropDownItem && dropDownItem.DropDownItems.Count > 0)

0 commit comments

Comments
 (0)