Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/System.Windows.Forms/System/Windows/Forms/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7518,14 +7518,16 @@ protected virtual void OnHandleDestroyed(EventArgs e)
((EventHandler?)Events[s_handleDestroyedEvent])?.Invoke(this, e);

// The Accessibility Object for this Control
if (Properties.TryGetValue(s_accessibilityProperty, out ControlAccessibleObject? accObj))
if (Properties.TryGetValue(s_accessibilityProperty, out AccessibleObject? accObj)
&& accObj is ControlAccessibleObject controlAccObj)
{
accObj.Handle = IntPtr.Zero;
controlAccObj.Handle = IntPtr.Zero;
}

// Private accessibility object for control, used to wrap the object that
// OLEACC.DLL creates to represent the control's non-client (NC) region.
if (Properties.TryGetValue(s_ncAccessibilityProperty, out ControlAccessibleObject? nonClientAccessibleObject))
if (Properties.TryGetValue(s_ncAccessibilityProperty, out AccessibleObject? ncAccObj)
&& ncAccObj is ControlAccessibleObject nonClientAccessibleObject)
{
nonClientAccessibleObject.Handle = IntPtr.Zero;
}
Expand Down
Loading