Skip to content

Commit

Permalink
Cleanup IOleControl interface (#2311)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughbe authored and RussKie committed Nov 8, 2019
1 parent 6184aa6 commit 8c2eaef
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 58 deletions.
34 changes: 34 additions & 0 deletions src/Common/src/Interop/Ole32/Interop.IOleControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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;
using System.Runtime.InteropServices;

internal partial class Interop
{
internal static partial class Ole32
{
[ComImport]
[Guid("B196B288-BAB4-101A-B69C-00AA00341D07")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public unsafe interface IOleControl
{
[PreserveSig]
HRESULT GetControlInfo(
CONTROLINFO* pCI);

[PreserveSig]
HRESULT OnMnemonic(
User32.MSG* pMsg);

[PreserveSig]
HRESULT OnAmbientPropertyChange(
Ole32.DispatchID dispID);

[PreserveSig]
HRESULT FreezeEvents(
BOOL bFreeze);
}
}
}
22 changes: 0 additions & 22 deletions src/Common/src/UnsafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,28 +1162,6 @@ int GetDropTarget(
[Out, MarshalAs(UnmanagedType.Interface)] object ppDropTarget);
};

[ComImport]
[Guid("B196B288-BAB4-101A-B69C-00AA00341D07")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public unsafe interface IOleControl
{
[PreserveSig]
HRESULT GetControlInfo(
Ole32.CONTROLINFO* pCI);

[PreserveSig]
HRESULT OnMnemonic(
User32.MSG* pMsg);

[PreserveSig]
HRESULT OnAmbientPropertyChange(
Ole32.DispatchID dispID);

[PreserveSig]
HRESULT FreezeEvents(
BOOL bFreeze);
}

[ComImport]
[Guid("0000010d-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@
<Compile Include="..\..\Common\src\Interop\NtDll\Interop.RtlGetVersion.cs" Link="Interop\NtDll\Interop.RtlGetVersion.cs" />
<Compile Include="..\..\Common\src\Interop\Ole32\Interop.ADVF.cs" Link="Interop\Ole32\Interop.ADVF.cs" />
<Compile Include="..\..\Common\src\Interop\Ole32\Interop.CALLCONV.cs" Link="Interop\Ole32\Interop.CALLCONV.cs" />
<Compile Include="..\..\Common\src\Interop\Ole32\Interop.CONTROLINFO.cs" Link="Interop\Ole32\Interop.CONTROLINFO.cs" />
<Compile Include="..\..\Common\src\Interop\Ole32\Interop.CTRLINFO.cs" Link="Interop\Ole32\Interop.CTRLINFO.cs" />
<Compile Include="..\..\Common\src\Interop\Ole32\Interop.DESCKIND.cs" Link="Interop\Ole32\Interop.DESCKIND.cs" />
<Compile Include="..\..\Common\src\Interop\Ole32\Interop.DispatchId.cs" Link="Interop\Ole32\Interop.DispatchId.cs" />
<Compile Include="..\..\Common\src\Interop\Ole32\Interop.DISPPARAMS.cs" Link="Interop\Ole32\Interop.DISPPARAMS.cs" />
Expand Down
7 changes: 3 additions & 4 deletions src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ internal class AxFlags
private object instance;
private Ole32.IOleInPlaceObject iOleInPlaceObject;
private UnsafeNativeMethods.IOleObject iOleObject;
private UnsafeNativeMethods.IOleControl iOleControl;
private Ole32.IOleControl iOleControl;
private Ole32.IOleInPlaceActiveObject iOleInPlaceActiveObject;
private Ole32.IOleInPlaceActiveObject iOleInPlaceActiveObjectExternal;
private Ole32.IPerPropertyBrowsing iPerPropertyBrowsing;
Expand Down Expand Up @@ -1016,8 +1016,7 @@ private void OnComponentRename(object sender, ComponentRenameEventArgs e)
{
// if it is, call DISPID_AMBIENT_DISPLAYNAME directly on the
// control itself.
//
if (GetOcx() is UnsafeNativeMethods.IOleControl oleCtl)
if (GetOcx() is Ole32.IOleControl oleCtl)
{
oleCtl.OnAmbientPropertyChange(Ole32.DispatchID.AMBIENT_DISPLAYNAME);
}
Expand Down Expand Up @@ -3920,7 +3919,7 @@ private AxContainer GetParentContainer()
return container;
}

private UnsafeNativeMethods.IOleControl GetOleControl() => iOleControl ??= (UnsafeNativeMethods.IOleControl)instance;
private Ole32.IOleControl GetOleControl() => iOleControl ??= (Ole32.IOleControl)instance;

private Ole32.IOleInPlaceActiveObject GetInPlaceActiveObject()
{
Expand Down
21 changes: 1 addition & 20 deletions src/System.Windows.Forms/src/System/Windows/Forms/Control.Ime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,7 @@ namespace System.Windows.Forms
/// <summary>
/// Control's IME feature.
/// </summary>
public partial class Control :
Component,
UnsafeNativeMethods.IOleControl,
UnsafeNativeMethods.IOleObject,
Ole32.IOleInPlaceObject,
Ole32.IOleInPlaceActiveObject,
Ole32.IOleWindow,
UnsafeNativeMethods.IViewObject,
UnsafeNativeMethods.IViewObject2,
UnsafeNativeMethods.IPersist,
Ole32.IPersistStreamInit,
UnsafeNativeMethods.IPersistPropertyBag,
Ole32.IPersistStorage,
UnsafeNativeMethods.IQuickActivate,
ISupportOleDropSource,
IDropTarget,
ISynchronizeInvoke,
IWin32Window,
IArrangedElement,
IBindableComponent
public partial class Control
{
/// <summary>
/// Constants starting/ending the WM_CHAR messages to ignore count. See ImeWmCharsToIgnore property.
Expand Down
10 changes: 5 additions & 5 deletions src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace System.Windows.Forms
]
public partial class Control :
Component,
UnsafeNativeMethods.IOleControl,
Ole32.IOleControl,
UnsafeNativeMethods.IOleObject,
Ole32.IOleInPlaceObject,
Ole32.IOleInPlaceActiveObject,
Expand Down Expand Up @@ -13771,7 +13771,7 @@ void ISupportOleDropSource.OnQueryContinueDrag(QueryContinueDragEventArgs queryC
OnQueryContinueDrag(queryContinueDragEventArgs);
}

unsafe HRESULT UnsafeNativeMethods.IOleControl.GetControlInfo(Ole32.CONTROLINFO* pCI)
unsafe HRESULT Ole32.IOleControl.GetControlInfo(Ole32.CONTROLINFO* pCI)
{
if (pCI == null)
{
Expand All @@ -13796,7 +13796,7 @@ unsafe HRESULT UnsafeNativeMethods.IOleControl.GetControlInfo(Ole32.CONTROLINFO*
return ActiveXInstance.GetControlInfo(pCI);
}

unsafe HRESULT UnsafeNativeMethods.IOleControl.OnMnemonic(User32.MSG* pMsg)
unsafe HRESULT Ole32.IOleControl.OnMnemonic(User32.MSG* pMsg)
{
if (pMsg == null)
{
Expand All @@ -13810,7 +13810,7 @@ unsafe HRESULT UnsafeNativeMethods.IOleControl.OnMnemonic(User32.MSG* pMsg)
return HRESULT.S_OK;
}

HRESULT UnsafeNativeMethods.IOleControl.OnAmbientPropertyChange(Ole32.DispatchID dispID)
HRESULT Ole32.IOleControl.OnAmbientPropertyChange(Ole32.DispatchID dispID)
{
Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:OnAmbientPropertyChange. Dispid: " + dispID);
Debug.Indent();
Expand All @@ -13819,7 +13819,7 @@ HRESULT UnsafeNativeMethods.IOleControl.OnAmbientPropertyChange(Ole32.DispatchID
return HRESULT.S_OK;
}

HRESULT UnsafeNativeMethods.IOleControl.FreezeEvents(BOOL bFreeze)
HRESULT Ole32.IOleControl.FreezeEvents(BOOL bFreeze)
{
Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:FreezeEvents. Freeze: " + bFreeze);
ActiveXInstance.EventsFrozen = bFreeze.IsTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class WebBrowserBase : Control
private UnsafeNativeMethods.IOleObject axOleObject;
private Ole32.IOleInPlaceObject axOleInPlaceObject;
private Ole32.IOleInPlaceActiveObject axOleInPlaceActiveObject;
private UnsafeNativeMethods.IOleControl axOleControl;
private Ole32.IOleControl axOleControl;
private WebBrowserBaseNativeWindow axWindow;
// We need to change the size of the inner ActiveX control before the
//WebBrowserBase control's size is changed (i.e., before WebBrowserBase.Bounds
Expand Down Expand Up @@ -1115,10 +1115,10 @@ private void AttachInterfacesInternal()
axOleObject = (UnsafeNativeMethods.IOleObject)activeXInstance;
axOleInPlaceObject = (Ole32.IOleInPlaceObject)activeXInstance;
axOleInPlaceActiveObject = (Ole32.IOleInPlaceActiveObject)activeXInstance;
axOleControl = (UnsafeNativeMethods.IOleControl)activeXInstance;
//
// Lets give the inheriting classes a chance to cast
// the ActiveX object to the appropriate interfaces.
axOleControl = (Ole32.IOleControl)activeXInstance;

// Give the inheriting classes a chance to cast the ActiveX object to the
// appropriate interfaces.
AttachInterfaces(activeXInstance);
}

Expand Down

0 comments on commit 8c2eaef

Please sign in to comment.