Home › Forums › General XMetaL Discussion › Interacting with running XMAX › Reply To: Interacting with running XMAX
Reply to: Interacting with running XMAX
July 11, 2011 at 6:22 amI've got E_NOINTERFACE error.
Here is a fragment of VB .NET code of the container app:
[code]
Public Shared Function RegisterActiveObject(
End Function
Public Shared Function RevokeActiveObject(ByVal pdwRegister As Integer, ByVal pvReserved As Integer) As Integer
End Function
Public Function Register_OLE32(ByVal itemname As String, ByRef obj As Object) As Integer
Dim enc As New UnicodeEncoding
Dim errorcode As Integer
Dim guid As New Guid
Dim registered As Integer
Dim item As Byte() = enc.GetBytes(itemname)
errorcode = CLSIDFromString(item, guid)
Marshal.ThrowExceptionForHR(errorcode)
'ACTIVEOBJECT_WEAK is 1
errorcode = RegisterActiveObject(obj, guid, 1, registered)
Marshal.ThrowExceptionForHR(errorcode)
Return registered
End Function
Public Sub Unregister_OLE32(ByVal id As Integer)
RevokeActiveObject(id, 0)
End Sub
Public Shared Function CLSIDFromString(ByVal lpszCLSID As Byte(), ByRef pclsid As Guid) As Integer
End Function
Private xmaxROTid As Integer
Private Sub XMActiveX_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.FindReplaceDlg = New FindReplaceForm()
Me.FindReplaceDlg.SetXMetaLActiveX(Me.AxXMetaLControl) ' FindReplaceDlg needs to know which XMetaL Control to Find and Replace, etc
Me.ValidationErrorDlg = New ValidationForm()
Me.ValidationErrorDlg.SetXMetaLActiveX(Me.AxXMetaLControl)
xmaxROTid = Register_OLE32(“XMetaL.Control”, Me.AxXMetaLControl)
End Sub
Private Sub XMActiveX_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Unregister_OLE32(xmaxROTid)
End Sub
[/code]
I am not trying to get the IXMetaLControl instance within macros. I create my plugin instance via CreateObject call in the On_Macro_File_Load handler. In the FinalConstruct method (C++ project) of the plugin I try to get the IXMetaLControl instance.