Author: jpobst Date: 2008-02-20 14:46:31 -0500 (Wed, 20 Feb 2008) New Revision: 96295
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBox.cs Log: 2008-02-20 Jonathan Pobst <[EMAIL PROTECTED]> * MessageBox.cs: Make the message box wider if the form caption is longer than the text in the form. [Fixes bug #361137] Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog 2008-02-20 19:25:16 UTC (rev 96294) +++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog 2008-02-20 19:46:31 UTC (rev 96295) @@ -1,3 +1,9 @@ +2008-02-20 Jonathan Pobst <[EMAIL PROTECTED]> + + * MessageBox.cs: Make the message box wider if the form caption + is longer than the text in the form. + [Fixes bug #361137] + 2008-02-20 Ivan N. Zlatev <[EMAIL PROTECTED]> * PropertyGridView.cs: Fix a NRE when closing the drop down form. Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBox.cs =================================================================== --- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBox.cs 2008-02-20 19:25:16 UTC (rev 96294) +++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MessageBox.cs 2008-02-20 19:46:31 UTC (rev 96295) @@ -263,11 +263,18 @@ // Calculate the width based on amount of buttons tb_width = (button_width + button_space) * buttoncount; + // The form caption can also make us bigger + SizeF caption = TextRenderer.MeasureString (Text, new Font (DefaultFont, FontStyle.Bold)); + + // Use the bigger of the caption size (plus some arbitrary borders/close button) + // or the text size, up to 60% of the screen (max_size) + Size new_size = new SizeF (Math.Min (Math.Max (caption.Width + 40, tsize.Width), max_width), tsize.Height).ToSize (); + // Now we choose the good size for the form - if (tsize.ToSize ().Width > tb_width) - this.ClientSize = new Size(tsize.ToSize().Width + (space_border * 2), Height = tsize.ToSize ().Height + (space_border * 4)); + if (new_size.Width > tb_width) + this.ClientSize = new Size (new_size.Width + (space_border * 2), Height = new_size.Height + (space_border * 4)); else - this.ClientSize = new Size(tb_width + (space_border * 2), Height = tsize.ToSize ().Height + (space_border * 4)); + this.ClientSize = new Size (tb_width + (space_border * 2), Height = new_size.Height + (space_border * 4)); // Now we set the left of the buttons button_left = (this.ClientSize.Width / 2) - (tb_width / 2) + 5; _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches