From 1f53cec80b2e7a2f748db52dae6592b711c40670 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:40:40 +0100 Subject: [PATCH] fix AdjustDescriptionHeightToFit calculation - closes #3962 --- src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index 8bdda06e54..93c99f6b69 100644 --- a/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -324,7 +324,7 @@ namespace BizHawk.Client.EmuHawk => !e.Alt && e.Control && e.Shift && e.KeyCode == key; /// - /// Changes the description heigh area to match the rows needed for the largest description in the list + /// Changes the description height area to match the rows needed for the largest description in the list /// public static void AdjustDescriptionHeightToFit(this PropertyGrid grid) { @@ -349,8 +349,9 @@ namespace BizHawk.Client.EmuHawk { var field = control.GetType().GetField("userSized", BindingFlags.Instance | BindingFlags.NonPublic); field?.SetValue(control, true); - int height = (int)Graphics.FromHwnd(control.Handle).MeasureString(desc, control.Font, grid.Width).Height; - control.Height = Math.Max(20, height) + 16; // magic for now + using var label = new Label(); + var maxSize = new Size(grid.Width - 9, 999999); + control.Height = label.Height + TextRenderer.MeasureText(desc, control.Font, maxSize, TextFormatFlags.WordBreak).Height; return; } }