#endregion // AxHost Subclasses
//private int flags;
- //private Guid clsid;
+ private Guid clsid;
+ private object instance;
private AboutBoxDelegate aboutDelegate = null;
private AxHost.State ocxState = null;
#region Protected Constructors
- [MonoTODO]
protected AxHost (string clsid) : this(clsid, 0)
{
}
- [MonoTODO]
protected AxHost (string clsid, int flags)
{
- //this.clsid = new Guid(clsid);
+ this.clsid = new Guid(clsid);
//this.flags = flags;
+ this.instance = null;
}
#endregion // Public Instance Properties
[EditorBrowsable (EditorBrowsableState.Advanced)]
public object GetOcx ()
{
- throw new NotImplementedException("COM/ActiveX support is not implemented");
+ return instance;
}
public bool HasPropertyPages ()
#region Protected Instance Methods
protected virtual void AttachInterfaces ()
{
- throw new NotImplementedException("COM/ActiveX support is not implemented");
+
}
protected override void CreateHandle ()
{
- if(!base.IsHandleCreated)
- base.CreateHandle();
+ if(!base.IsHandleCreated) {
+ GetActiveXInstance ();
+ AttachInterfaces ();
+
+ base.CreateHandle ();
+ }
+ }
+
+ private void GetActiveXInstance()
+ {
+ if (this.instance == null) {
+ object obj;
+ CoCreateInstance (ref clsid, null, 1, ref IID_IUnknown, out obj);
+ this.instance = obj;
+ }
}
protected virtual object CreateInstanceCore (Guid clsid)
throw new NotImplementedException("COM/ActiveX support is not implemented");
}
+
[EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void CreateSink ()
{
protected override void Dispose (bool disposing)
{
+ if(disposing) {
+ if(this.instance != null)
+ Marshal.ReleaseComObject (this.instance);
+ this.instance = null;
+ }
base.Dispose(disposing);
}
throw new NotImplementedException("COM/ActiveX support is not implemented");
}
#endregion // Interfaces
+
+ static Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
+
+ [DllImport("ole32.dll")]
+ static extern int CoCreateInstance (
+ [In] ref Guid rclsid,
+ [In, MarshalAs (UnmanagedType.IUnknown)] object pUnkOuter,
+ [In] uint dwClsContext,
+ [In] ref Guid riid,
+ [Out, MarshalAs (UnmanagedType.Interface)] out object ppv);
+
}
}