Link to home
Start Free TrialLog in
Avatar of Carpathia
Carpathia

asked on

ActiveX Forms

I am trying to develop an application which allows clients to develop their own ActiveX plugins which will appear in my app as form.

I have created an ActiveForm, which resides in test.ocx. In my client app I scan a directory at runtime, and register the test.ocx using LoadLibrary and GetProcAddress(RegisterDLL).

However, Im having problems creating and displaying the form.

When I use CreateOLEObject and (loading the result into an OLEVariant), the function returns an IDispatch interface to my AX form object. This IDispatch has no methods which allow me to show the form.

So my question is, how do I get at my form, from this IDispatch ?
I want to be able to access the underlying form via properties or methods such as Top, Left and Show, ShowModal.

Sample source much appreciated, but a good explanation will earn the points.

Thanks !
Avatar of Epsylon
Epsylon

Drop an OleContainer (System tab) on your form.

To load an ActiveX form into the container use this code:

  OleContainer1.AutoActivate := aaManual;
  OleContainer1.CreateObject('XXXXProj1.XXXXX', false);
  OleContainer1.DoVerb(ovShow);

XXXXX is the name of the object.


If you want to access components on the ActiveX form you have to publish your own methods and properties in the Type Library editor.

Eps.
Avatar of Carpathia

ASKER

Thanks eps. This solves the showing of the form, but still doesnt allow me access to top and left etc..

But Im really looking for a way to take my IDispatch from CreateOLEObject, and get access to the TActiveForm? or at least get hold of some other interface which defines top, left etc.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks :)

I intiially thought your comment about the type library related just to components on the form, not the methods of the form itself.
Instead of

OleContainer1.DoVerb(ovShow);

mybe you can better use

OleContainer1.Run;


Eps.