OleComponent Class


Basic implementation of a disposable IOleComponent

public ref class OleComponent : Microsoft::VisualStudio::PlatformUI::DisposableObject, Microsoft::VisualStudio::OLE::Interop::IOleComponent, Microsoft::VisualStudio::Shell::Interop::IVsDiagnosticsItem
class OleComponent : Microsoft::VisualStudio::PlatformUI::DisposableObject, Microsoft::VisualStudio::OLE::Interop::IOleComponent, Microsoft::VisualStudio::Shell::Interop::IVsDiagnosticsItem
public class OleComponent : Microsoft.VisualStudio.PlatformUI.DisposableObject, Microsoft.VisualStudio.OLE.Interop.IOleComponent, Microsoft.VisualStudio.Shell.Interop.IVsDiagnosticsItem
type OleComponent = class
    inherit DisposableObject
    interface IOleComponent
    interface IVsDiagnosticsItem
Public Class OleComponent
Inherits DisposableObject
Implements IOleComponent, IVsDiagnosticsItem


Defines virtual methods for derived classes to override in order to change behavior. Also defines a public event for each method that users can hook into to change behavior without deriving. Default implementations of virtual methods simply raise events in the presence of handlers. If you derive and override the methods and want the events to be raised call the base method before or after your override logic. Will call FRegisterComponent(IOleComponent, OLECRINFO[], UInt32) on construction and and FRevokeComponent(UInt32) on Dispose().


OleComponent(IOleComponentManager, String)

Construct an instance of OleComponent. This overload will call FRegisterComponent(IOleComponent, OLECRINFO[], UInt32) automatically on construction.



Microsoft internal use only.


Returns whether the object has been disposed once, protects against double disposal

(Inherited from DisposableObject)

Sets whether this component is the tracking component, accomplished by calling FSetTrackingComponent(UInt32, Int32).


Sets or retrieves the idle time period in milliseconds for this components idle callbacks.



Activates the component, accomplished by calling FOnComponentActivate(UInt32).


Makes this IOleComponent the tracking component with its associated IOleComponentManager.


Creates a new OleComponent instance using Instance as the IOleComponentManager it needs to register itself.


Disposes the current object then suppresses further finalization.

(Inherited from DisposableObject)

Standard virtual overload for IDisposable pattern

(Inherited from DisposableObject)

Disposes of this object, calling FRevokeComponent(UInt32) if our manager field is non-null and our componentCookie field is not 0.


Allows derived classes to provide custom dispose handling for native resources

(Inherited from DisposableObject)
DoOleEvents(IOleComponentManager, Func<Boolean>)

Message pump for an IOleComponentManager.

WARNING: Do not call this method unless it is absolutely necessary, and you know what you are doing. Pumping UI messages can have bad, bad side effects.

See: https://blogs.msdn.com/jfoscoding/archive/2005/08/06/448560.aspx


Makes this IOleComponent no longer the tracking component with its associated IOleComponentManager.

FContinueMessageLoopCore(UInt32, IntPtr, MSG[])

Default implementation of FContinueMessageLoop. Simply raises the ContinueMessageLoop event if there are any listeners.


Default implementation of FDoIdle. Simply raises the DoIdle and DoPeriodicIdle events as appropriate (based on value of ) if there are any listeners.


Default implemmentation of FPreTranslateMessage. Simply raises the PreTranslateMessage event if there are listeners.


Default implemmentation of FQueryTerminate. Simply raises the QueryTerminate event if there are listeners.

HwndGetWindowCore(UInt32, UInt32)

Default implemmentation of HwndGetWindow. Simply raises the GetWindow event if there are listeners.

OnActivationChangeCore(IOleComponent, Int32, OLECRINFO[], Int32, OLECHOSTINFO[], UInt32)

Default implemmentation of OnActivationChange. Simply raises the ActivationChange event if there are listeners.

OnAppActivateCore(Int32, UInt32)

Default implemmentation of OnAppActivate. Simply raises the AppActivate event if there are listeners.

OnChangeStateCore(UInt32, Int32)

Default implemmentation of OnEnterState. Simply raises the approriate event based on what state changed (described in ComponentState.


Default implemmentation of OnLoseActivation. Simply raises the ActivationLost event if there are listeners.

PushMessageLoop(_OLELOOP, IntPtr)

Pushes this component to the OleComonentManager as the message loop handler by calling FPushMessageLoop(UInt32, UInt32, IntPtr). Message loop blocks until an ContinueMessageLoop handler sets the ContinuePumping /// to false.


Default implemmentation of Terminate. Simply raises the Terminate event if there are listeners. Also calls Dispose() and nulls out any reference to a IOleComponentManager that we may have been constructed with.


Throws an ObjectDisposedException if this object has been disposed

(Inherited from DisposableObject)



Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Raised when the event is being disposed, while it is still accessible.

(Inherited from DisposableObject)

Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.


Microsoft internal use only.

Explicit Interface Implementations

IOleComponent.FContinueMessageLoop(UInt32, IntPtr, MSG[])

Called during each iteration of a message loop that the component pushed. Simply calls through to FContinueMessageLoopCore(UInt32, IntPtr, MSG[]).


Called to give a component a chance to do idle time tasks. Component may periodically call FContinueIdle(); if this method returns FALSE (0), component should terminate its idle time processing and return. Simply calls through to FDoIdleCore(UInt32).


Host calls this method on the active component (if its registration info (ComponentRegistrationFlags) indicates it is interested in Pre-translate calls) to give the component a chance to process messages before they are translated and dispatched. The host need not call this method if no component is active. Simply calls through to FPreTranslateMessageCore(MSG[]).


Called when component manager wishes to know if the component is in a state in which it can terminate. Simply calls through to FQueryTerminateCore(Int32).

IOleComponent.FReserved1(UInt32, UInt32, IntPtr, IntPtr)

Reserved slot, not called.

IOleComponent.HwndGetWindow(UInt32, UInt32)

Called to retrieve a window associated with the component, as specified by dwWhich which maps to a value in WindowType. Simply calls through to HwndGetWindowCore(UInt32, UInt32).

IOleComponent.OnActivationChange(IOleComponent, Int32, OLECRINFO[], Int32, OLECHOSTINFO[], UInt32)

Notify component when a new object is being activated. Simply calls through to OnActivationChangeCore(IOleComponent, Int32, OLECRINFO[], Int32, OLECHOSTINFO[], UInt32).

IOleComponent.OnAppActivate(Int32, UInt32)

Notify component when the host application gains or loses activation. Simply calls through to OnAppActivateCore(Int32, UInt32).

IOleComponent.OnEnterState(UInt32, Int32)

Notify component when app enters or exits the state given in uStateID. Simply calls through to OnChangeStateCore(UInt32, Int32).


Notify the active component that it has lost its active status because the host or another component has become active. Simply calls through to OnLoseActivationCore().


Called when component manager wishes to terminate the component's registration. Component should revoke its registration with component manager, release references to component manager and perform any necessary cleanup. Simply calls through to TerminateCore().

Applies to