PDA

View Full Version : Newbie Question: using ActiveX in AMS 7.5


SGW
02-12-2009, 09:25 AM
Hi,

I have an ActiveX control that does CAD drawing. Can AMS 7.5 create a container and call, via scripting, the ActiveX functions (like draw, print, etc.)?

I am trying to figure out if I can embed the ActiveX into an AMS 7.5 app so that it can be used as a drawing feature.

Any help clarifying this, lead to how it could be done, would be much appreciated.

Kind Regards,

SGW

ShadowUK
02-12-2009, 11:02 AM
I reckon you could use System.RegisterActiveX and the Luacom Plugin which is avaliable here (http://www.google.com/url?sa=t&source=web&ct=res&cd=3&url=http%3A%2F%2Fwww.icynorth.com%2Fluacom%2Findex .html&ei=LFaUSebQLsaI-ga3o-mFCQ&usg=AFQjCNFYzbVFODt8zqZXQr35f3OXNwZlZg&sig2=1OMvfxELEubWawcylM0GtA).

Dermot
02-12-2009, 11:14 AM
If it is a visual control, which I assume it is, then no you can't. The only way would be to create an object plugin that wraps the activex control. That's no easy task and depending on how complex the control is it may not even be possible.

Dermot
02-12-2009, 11:18 AM
I have found one or two activex controls that I have been able to embed in an AMS listbox and then use LuaCom to control them. The control has to have a parent hwnd property that you can set, which is very rare.

SGW
02-12-2009, 11:26 AM
Hi Dermot and ShadowUK,

Thanks for your suggestions. I've downloaded the plugin and it's PDF to see if I can figure it out.

It does appear that there is a hwnd available, so this may not be a problem.

The big challenge for me as an AMS beginner is whether I can figure out the scripting to successfully call functions in the ActiveX. The language that the ActiveX function calls is written in is C++, so getting these into LUA syntax will be a steep learning curve.

Kind Regards,

SGW

ShadowUK
02-12-2009, 11:37 AM
Hi Dermot and ShadowUK,

Thanks for your suggestions. I've downloaded the plugin and it's PDF to see if I can figure it out.

It does appear that there is a hwnd available, so this may not be a problem.

The big challenge for me as an AMS beginner is whether I can figure out the scripting to successfully call functions in the ActiveX. The language that the ActiveX function calls is written in is C++, so getting these into LUA syntax will be a steep learning curve.

Kind Regards,

SGW

If you know C++ you should take a look at the IndigoRose Product SDK. Maybe you could make it an object plugin.

SGW
02-12-2009, 11:48 AM
Hi ShadowUK,

I wish I knew C++. Unfortunately, all I was saying is that the ActiveX developer has written their help guide examples for function calls in C++.

Kind Regards,

SGW

ShadowUK
02-12-2009, 11:54 AM
Hi ShadowUK,

I wish I knew C++. Unfortunately, all I was saying is that the ActiveX developer has written their help guide examples for function calls in C++.

Kind Regards,

SGW

I wish I knew it too. :(

Dermot
02-12-2009, 12:14 PM
You don't need to know C++ to use an activex control with LuaCOM. Can you point me to a trial version of this control? I can generate a html file listing all the functions and properties and how to use them with LuaCOM.

SGW
02-12-2009, 12:32 PM
Hi Dermot,

Here's a link to a fully working, though unlicensed version, with complete help guide materials:

http://www.kolbasoft.com/vecad6.zip

The first challenge I would face is loading the ActiveX into an AMS project so that its basic drawing canvas would display in runtime.

Second challenge would be to figure out the function call to register the code that the developer sent to me, so that the "Unregistered Version" display no longer shows in the canvas window when running. The C++ guidelines to register this registration code and remove the unregistered display are in the help guide chm when searched for the word: "register."

Any help getting this started would provide a lot of learning, LUA scripting examples for function call and be much appreciated. :)

Kind Regards,

SGW

Dermot
02-12-2009, 02:09 PM
Attached is the Lib info which lists all the enumerations and functions. I don't think there is anyway to embed it in AMS though. You can access the functions using LuaCom, but it is not much use when you can't see anything.

This will display the about box.
vecad = luacom.CreateObject("VeCAD.Ctrl.1")

if vecad then
vecad:AboutBox()
else
Dialog.Message("Failed", "Could not create object")
end

Dermot
02-12-2009, 02:13 PM
You can register it like this.
vecad = luacom.CreateObject("VeCAD.Ctrl.1")

if vecad then
result = vecad:Registration(Your reg code)
if result then
--Registered
else
-- not registered
end
else
Dialog.Message("Failed", "Could not create object")
end

ShadowUK
02-12-2009, 02:18 PM
How did you do that Dermot? Getting the functions and stuff.

Also, this is not a newbie question. Quite an advanced one at that. :p

Dermot
02-12-2009, 02:30 PM
How did you do that Dermot? Getting the functions and stuff.

Also, this is not a newbie question. Quite an advanced one at that. :p
I used LuaCOM version 1.3. It has a DumpTypeLib function that creates the html file.

Dermot
02-12-2009, 02:43 PM
Here is an example project using LuaCOM 1.3. It generates the typelib info for the VeCAD control but you can change it to any control you want.

SGW
02-12-2009, 02:46 PM
H,

Yes, agreed, definitely not a newbie question. But, I need to try to get some drawing set up using the VeCad ActiveX for an educational project.

But first I would need to load VeCad into AMS. Are you saying that no matter how we would try, it cannot be loaded in a way that anything like the VeCad drawing canvas would show? If that's true, unfortunately, it can't work for the project, since the user needs to be able to use VeCad drawing interface to draw on.

If it can be successfully loaded into AMS using the plugin, and display the VeCad drawing canvas, then I could try the code to register it with the reg number sent to me.

If these both can be done, being a newbie, could you (1) suggest the load script in LUA and where to put it, and (2) where I would place the registration script in order to get it working. Very much a newbie and still learning my way around the AMS interface, syntax, etc.

Thanks for your help.

Kind Regards,

SGW

SGW
02-12-2009, 02:55 PM
Hi,

I downloaded the AMS sample plus library (library: by the way: Wow! impressive!), placed them in the same folder and ran the AMS sample. However, when I previewed it, it kept crashing the AMS program.

Am I doing something wrong?

Kind Regards,

SGW

Dermot
02-12-2009, 03:18 PM
There is no way that I can see to display the control in AMS. You would have to create a plugin which would be a huge amount of work.

The LuaCOM 1.3 example uses compat-lua which does not play nice on Vista. Works fine on XP. I only use it to get the TypeLiib info from activex controls. That example is not going to help you use VeCAD. I only posted it to show how I generated the TypeLib html file.

SGW
02-12-2009, 04:25 PM
OK, thanks for clarifying this. Doesn't seem likely that I can use this ActiveX in AMS.

SGW

ShadowUK
02-13-2009, 12:48 AM
Will this (http://indigorose.com/forums/showthread.php?t=25782) suffice?

SGW
02-13-2009, 07:43 AM
Hi ShadowUK,

Thanks very much for sharing this excellent sample. While it may not work for the drawing needed in my eLearning project (the user needs to be able to draw a diagram of their family tree with squares, circles, connecting lines, text, other shapes and fills, save and re-ope n the diagram for editing), this can help with my learning AMS and LUA.

Again, thanks.

Kind Regards,

SGW

SGW
02-16-2009, 07:05 PM
Hi,

I have been doing more reading about the availability of a display in VeCAD. It appears that both the VeCAD OCX and the VeCAD DLL have a way to create and display a Window to use as a drawing canvas.

If AMS can load and call functions in a DLL, then maybe another possibility is to use the VeCAD DLL (included in the VeCAD zip folder download-see posting above for link). The VeCAD help files included in the VeCAD trial version mention that the display can be called by first calling a VeCAD Object and then calling a VeCAD Window and provides the function calls.

As a newbie with limited LUA scripting ability, I don't think I can set this up. I wondered if the expert forum colleagues can take a look and determine if a display Window for drawing, using the VeCAD DLL, can work.

Any help determining if this is a possibility and then getting it tested would be much appreciated.

Kind Regards,

SGW