Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/class
diff options
context:
space:
mode:
authorKarl <5079870+PreferLinux@users.noreply.github.com>2020-01-28 18:32:51 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2020-01-28 18:32:51 +0300
commit1bfd3173624ffc875f4e91ca2efc8853f8f6caf0 (patch)
tree4e7b2d5bc1e51d017e0dc7b4c123d9e708eed84b /mcs/class
parent2fdafcf3a4fdf2a558667b4b594b6f40169b3afa (diff)
[Winforms] Form fixes (#18427)
* Fix Return handling. Ensure correct ClientSize. When pressing Return / Enter, ensure any target button is both visible and enabled. In CreateHandle(), ensure the ClientSize is correct if set. If not, update it to make it right. Suspend layout while changing it so that child controls with anchors other than Top Left are not moved. * Select active control. PerformLayout after updating for client size. Select the active control with SendControlFocus to avoid upsetting what is currently selected. * Improve Form window decoration adjustment handling Reverts the incorrect attempted fix contained in previous commits. Basically, when a property is changed that affects window decorations, ensure the client size stays the same. * Use UpdateFormStyles on FormBorderStyle too.
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs31
1 files changed, 20 insertions, 11 deletions
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
index 7f032754f70..fcd95416024 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
@@ -201,7 +201,11 @@ namespace System.Windows.Forms {
internal override void UpdateWindowText ()
{
+ var old_clientsize = ClientSize;
+
if (!IsHandleCreated) {
+ if (is_clientsize_set)
+ ClientSize = old_clientsize;
return;
}
@@ -213,6 +217,9 @@ namespace System.Windows.Forms {
}
XplatUI.Text (Handle, Text.Replace (Environment.NewLine, string.Empty));
+
+ if (ClientSize != old_clientsize)
+ ClientSize = old_clientsize;
}
internal void SelectActiveControl ()
@@ -236,7 +243,7 @@ namespace System.Windows.Forms {
this.is_visible = visible;
} else {
- Select (ActiveControl);
+ SendControlFocus (ActiveControl);
}
}
@@ -596,7 +603,7 @@ namespace System.Windows.Forms {
set {
if (control_box != value) {
control_box = value;
- UpdateStyles();
+ UpdateFormStyles();
}
}
}
@@ -662,15 +669,10 @@ namespace System.Windows.Forms {
window_manager.UpdateBorderStyle (value);
}
- Size current_client_size = ClientSize;
- UpdateStyles();
+ UpdateFormStyles();
- if (this.IsHandleCreated) {
- this.Size = InternalSizeFromClientSize (current_client_size);
+ if (this.IsHandleCreated)
XplatUI.InvalidateNC (this.Handle);
- } else if (is_clientsize_set) {
- this.Size = InternalSizeFromClientSize (current_client_size);
- }
}
}
@@ -1124,7 +1126,7 @@ namespace System.Windows.Forms {
set {
if (this.show_icon != value ) {
this.show_icon = value;
- UpdateStyles ();
+ UpdateFormStyles ();
if (IsHandleCreated) {
XplatUI.SetIcon (this.Handle, value == true ? this.Icon : null);
@@ -2197,7 +2199,7 @@ namespace System.Windows.Forms {
if (keyData == Keys.Enter) {
IntPtr window = XplatUI.GetFocus ();
Control c = Control.FromHandle (window);
- if (c is Button && c.FindForm () == this) {
+ if (c is Button && c.Visible && c.Enabled && c.FindForm () == this) {
((Button)c).PerformClick ();
return true;
}
@@ -2894,6 +2896,13 @@ namespace System.Windows.Forms {
is_loaded = true;
}
+ private void UpdateFormStyles() {
+ var old_clientsize = ClientSize;
+ UpdateStyles();
+ if ((!IsHandleCreated && is_clientsize_set) || ClientSize != old_clientsize)
+ ClientSize = old_clientsize;
+ }
+
private void UpdateMinMax()
{
var min_size = AutoSize ? new Size (Math.Max (minimum_auto_size.Width, minimum_size.Width), Math.Max (minimum_auto_size.Height, minimum_size.Height)) : minimum_size;