diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.AccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.AccessibleObject.cs new file mode 100644 index 00000000000..26e97f5dba2 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.AccessibleObject.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Drawing; + +namespace System.Windows.Forms +{ + public partial class Form + { + /// + /// Form control accessible object with UI Automation provider functionality. + /// This inherits from the base ControlAccessibleObject + /// to have all base functionality. + /// + internal class FormAccessibleObject : ControlAccessibleObject + { + private readonly Form _owner; + + internal FormAccessibleObject(Form owner) : base(owner) + { + _owner = owner; + } + + public override Rectangle Bounds => _owner.RectangleToScreen(_owner.ClientRectangle); + + internal override Rectangle BoundingRectangle => _owner.Bounds; + + internal override bool IsIAccessibleExSupported() + { + if (_owner != null) + { + return true; + } + + return base.IsIAccessibleExSupported(); + } + + internal override bool IsPatternSupported(int patternId) + { + if (patternId == NativeMethods.UIA_LegacyIAccessiblePatternId) + { + return true; + } + + return base.IsPatternSupported(patternId); + } + + internal override void SetValue(string newValue) + { + Value = newValue; + } + } + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs index 388d28ecd36..813f15ecace 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs @@ -31,7 +31,7 @@ namespace System.Windows.Forms DefaultEvent(nameof(Load)), InitializationEvent(nameof(Load)), ] - public class Form : ContainerControl + public partial class Form : ContainerControl { #if DEBUG static readonly BooleanSwitch AlwaysRestrictWindows = new BooleanSwitch("AlwaysRestrictWindows", "Always make Form classes behave as though they are restricted"); @@ -1707,10 +1707,10 @@ public Form[] MdiChildren } /// - /// Gets the MDIClient that the MDI container form is using to contain Multiple Document Interface (MDI) child forms, + /// Gets the MDIClient that the MDI container form is using to contain Multiple Document Interface (MDI) child forms, /// if this is an MDI container form. /// Represents the client area of a Multiple Document Interface (MDI) Form window, also known as the MDI child window. - /// + /// internal MdiClient MdiClient { get @@ -3361,6 +3361,11 @@ private Size ComputeWindowSize(Size clientSize, int style, int exStyle) return new Size(result.right - result.left, result.bottom - result.top); } + protected override AccessibleObject CreateAccessibilityInstance() + { + return new FormAccessibleObject(this); + } + [EditorBrowsable(EditorBrowsableState.Advanced)] protected override Control.ControlCollection CreateControlsInstance() { @@ -3552,7 +3557,7 @@ private void DeactivateMdiChild() /// a /// subclass overrides this function, /// it must call the base implementation. - /// + /// [ EditorBrowsable(EditorBrowsableState.Advanced) ] @@ -4252,7 +4257,7 @@ private protected override void OnAutoScaleModeChanged() base.OnAutoScaleModeChanged(); if (formStateEx[FormStateExSettingAutoScale] != 1) { - // Obsolete code required here for backwards compat + // Obsolete code required here for backwards compat #pragma warning disable 618 AutoScale = false; #pragma warning restore 618 @@ -5873,6 +5878,8 @@ internal bool ShouldSerializeTransparencyKey() return !TransparencyKey.Equals(Color.Empty); } + internal override bool SupportsUiaProviders => true; + /// /// This is called when we are about to become minimized. Laying out /// while minimized can be a problem because the physical dimensions @@ -6202,7 +6209,7 @@ internal void UpdateFormStyles() private static Type FindClosestStockType(Type type) { Type[] stockTypes = new Type[] { typeof(MenuStrip) }; // as opposed to what we had before... - // simply add other types here from most specific to most generic if we want to merge other types of toolstrips... + // simply add other types here from most specific to most generic if we want to merge other types of toolstrips... foreach (Type t in stockTypes) { if (t.IsAssignableFrom(type)) @@ -7343,7 +7350,7 @@ public override void Add(Control value) } /// - /// Removes a control from the form. + /// Removes a control from the form. /// public override void Remove(Control value) {