Pages: 1
Print
Author Topic: Migration from XMetaL to XMAX  (Read 639 times)
elias
Member

Posts: 13


« on: June 15, 2011, 05:37:47 AM »

Hello!
I've got a plugin (dll) for XMetaL written in C++ language (IDE - MS Visual Studio 2003). The plugin uses
classes like DOMElement (having COleDispatchDriver as a parent class).
dll methods (marked as STDMETHOD) are used via mcr-file in XMetaL 6.0.
How can I use this plugin in XMAX component? Will transfer to XMAX be difficult?
Are there any examples/tutorials for it (how to link XMControl.dll with dll functions)?
My task is to connect XMAX and my plugin. The containter application will be determined later.
So can I use VB.Net sample (XMActiveX_VBSample) as a container application?

Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1546



WWW
« Reply #1 on: June 16, 2011, 05:04:20 PM »

XMAX creates a script engine in the same manner as XMetaL Author. However, there is this difference between the two products:
• XMetaL Author injects 5 top-level objects (Application, Document, Documents, Selection, and ResourceManager).
• XMAX injects 2 top-level objects (ActiveDocument and Selection).

Because XMAX does not include the GUI to support Application, Documents, or ResourceManager it does not make sense to include them (you would build the equivalents of these into your GUI if you require them for your XMAX solution, and in that case you can create any interfaces that you need).

You say you are using COleDispatcher so you can likely avoid recompiling your DLL (even though XMAX has a different type library). In other words, your use of IDispatch to call DOMElement methods and properties should work fine with XMAX.

Note that XMAX fires the same document-level event macros as XMetaL Author (On_Macro_File_Load, On_Document_Open_Complete, On_Update_UI, etc). XMAX uniquely reflects some of these event macros to the container application via an event sink called _IXMetaLControlEvents.

« Last Edit: June 16, 2011, 05:16:03 PM by Derek Read » Logged
elias
Member

Posts: 13


« Reply #2 on: June 17, 2011, 07:14:57 AM »

OK, thank you!
But how XMAX component will know about MCR which contains event handlers?
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1546



WWW
« Reply #3 on: June 17, 2011, 12:02:14 PM »

If you need XMAX to load an MCR file you have two options:

1. Build a XAC file using XMetaL Developer that contains your customizations files, including the MCR file. Then as part of your XMAX code use the parameter that tells it to load a specific XAC file when loading an XML document.
2. Place your MCR file in the same location as the DTD or XSD that XMAX is loading (usually based on the SYSTEM id in the DOCTYPE declaration in the XML or the schemaLocation attribute) and give the MCR file the same name as the DTD or XSD. It will then be loaded. If you want your CSS and CTM file to be loaded this way they must also have the same filename:
myschema.dtd
myschema.mcr
myschema.css
myschema.ctm
Logged
elias
Member

Posts: 13


« Reply #4 on: June 24, 2011, 07:41:22 AM »

XMAX is embedded into XMActiveX_VBSample. XMActiveX_VBSample runs and loads xac-file into XMAX object. The corresponding mcr-script tells XMAX to create another ActiveX object (as a plugin).
Should this ActiveX plugin attach dispatch or create dispatch (in terms of MFC library) in order to work with the embedded XMAX?
Unfortunately I can't detect the running instance of XMAX. By the way, are there any standard means to detect the items in ROT (Running Object Table)?
I have used CLSIDFromProgID (getting CLSID from "XMetaL.Control" string) and GetActiveObject in order to check for existing XMAX, but the check fails.
Can you show me some piece of code which shows the correct way of linking running XMAX object with another ActiveX object?
May be, there are some peculiarities with XMAX. For example, I've read that the usage of GetActiveObject for Excel required that the focus had to be moved away from Excel window (http://support.microsoft.com/kb/238610/en-us).         
Logged
elias
Member

Posts: 13


« Reply #5 on: June 30, 2011, 08:08:04 AM »

Now I am able to add the XMAX object to the ROT with the help of RegisterActiveObject.
GetActiveObject works fine, but I've got DISP_E_MEMBERNOTFOUND error
when I try to show About box. This method works fine within VB .NET sample container application and within
ActiveX Control Test Container.
The wizard has made wrapper. This is a fragment from the generated .h-file:

void ShowAbout()
{
  InvokeHelper(0x10, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
Logged
Pages: 1
Print
Jump to: