Fog Creek Software
Discussion Board

wrapping an app as an activeX control

We would like to offer our windows application as an ActiveX control - unfortunately we don't have any ActiveX expertise.*

Is there a product out there which would take an existing windows application and convert it into a simple activex control with just a start method which runs the full app in a window.

* and to make it even more interesting, it's a wxWindows app not MFC/.Net.

Martin Beckett
Sunday, August 15, 2004

I don't know of a tool that converts the source code of a standard EXE project into an ActiveX control project, but the two are pretty similar, with just a few caveats when writing an ActiveX control:

- The chain of events is Initialize, followed by InitProperties, possibly ReadProperty or WriteProperty, and Terminate
- If the control shows forms, they can only be shown as modal
- if a form has a menu, it'll be mixed with IE's
- XPSP2 seems to make it compulsory to sign all ActiveX controls with Authenticode when shown in a web browser
- Make sure all errors are trapped with an error handler, as errors in an ActiveX controls in a web page may end with just a grey square with no indication about what went wrong (missing dependency, etc)
- Use the Ambient object (the container of the ActiveX) to get its properties such as background color
- Enable binary compatibility to avoid changing the control's CLSID in the web page after every compiling...

Sunday, August 15, 2004

Thanks - I was hoping there was a way of patching the .exe repalcing the startup routines with an activeX startup.
I hadn't considered how to handle dialog boxes and errors.

Martin Beckett
Sunday, August 15, 2004

... and I mistakenly thought the original EXE was in VB, while obviously, it's in C++ (MFC, wxWidgets.) Considering the complexity, I doubt anyone came up with a tool to turn this kind of project into an ActiveX control automagically.

Maybe it's easier to turn it into an ActiveX EXE ("out of process" control), and just write a tiny standard EXE whose sole role would be to drive the new EXE?

Sunday, August 15, 2004

If you're using VC++ (6.0), use the wizards to quickly create the "hello world" ActiveX. Then add your other files into the project, and tap into the various On... methods and WM_PAINT, etc, to call your appropriate code.

Sunday, August 15, 2004

Hoo boy, you're in for a world of hurt.

First, a bit of terminology. "ActiveX control" refers to a COM object that has a user interface that's displayed as a child window (or windowless, but lets not get into that wrinkle right now). So, technically, what you're describing (call the object and get a top level window) is not an ActiveX control.

If you want to do what you described, then you CAN build an exe COM server. Then you can have a single COM object which, when created, throws up your UI and runs your application.

In general, this type of COM object fundamentally sucks. The programatic interface usually revolves around manipulating the UI, and it's impossible to use without display the user interface, which makes it very hard to use the COM object as a server.

Ideally, what you should do is make sure that you've separated your logic and your UI into separate layers. Implement the logic as a COM server (exe or dll, your choice). Then write your UI so that it calls the logic layer via COM. That way you can do your functions either via the existing application, or call into your logic via COM from VB or whatever.

If you need special displays, implement those as ActiveX controls.

Chris Tavares
Sunday, August 15, 2004

>>We would like to offer our windows application as an ActiveX control - unfortunately we don't have any ActiveX expertise.*

I'd start by thinking a bit harder about why you want to do this, are you planning to offer it as a component  to other developers so they can integrate into their application or do you need to provide a mechanism for automating your own application. If its the second perhaps you should look at the active scripting interfaces (easy) or VBA (hard.)

Either way if you plan on doing a thorough job you are going to be going back to basics on a lot of the code. Your aren't likely to find a tool which just magically solves everything for you.

Tony Edgecombe
Monday, August 16, 2004

Thanks for all your help.

The application is a gui front end to an engine.
The engine is already embeddable in other apps but someone wanted to embed the gui as well.
But the gui is written in wxWindows and no one here as any activeX experience.

Looks like this more work than is reasonable - an interesting solution is to run the gui on linux, use vncviewer as an activeX control viewing it in a window.

Martin Beckett
Monday, August 16, 2004

Here's a pretty decent article I found on writing ActiveX controls and containers:

(I used it as one of my references for making a simple ActiveX control container.)

Monday, August 16, 2004

Take a look at PythonCOM:

Ged Byrne
Monday, August 16, 2004

Hmmm, using PythonCOM to develop an ActiveX control looks to be tricky:

Ged Byrne
Monday, August 16, 2004

> First, a bit of terminology. "ActiveX control" refers to a COM object that has a user interface that's displayed as a child window ...

An old definition from the OLE days.  MSDN has a number of conflicting definitions of an ActiveX Control, including the tautological "an OLE object that supports the IUnknown interface".  Other definitions on MSDN go further and imply that to be considered an ActiveX control, a COM object must be self-registering, and perhaps an in-proc object (DLL).

Saturday, August 21, 2004

The easy approach: Get out your checkbook and talk to TT Solutions, who appear to be the resident ActiveX gurus in the world of wxWidgets.

If it's doable at all, they'll know, and can probably quote you a very reasonable schedule.

I'm a very satisfied client of theirs--my employer hired them to convert an existing Win32 application to a subclass of wxWindow, and they did it in under a week.

In general, when dealing with open source toolkits, look at the dev lists. There's always somebody who runs a consulting business, frequently an extremely competent one.

J. Random Hacker
Monday, August 30, 2004

*  Recent Topics

*  Fog Creek Home