Click to See Complete Forum and Search --> : Beginner ActiveX question


Tim
August 24th, 1999, 06:06 PM
I am experimenting with an ActiveX app that has no window. Just as an experiment I made a windowless ActiveX control that has only one interface (added by me): Add5().
This function takes a long as it's input and returns the value with 5 added to it.

OK, well, creating the control was no big deal, but using it looks like a real bear. If I create a very simple MFC dialog based app and drop the control onto the dialog, I don't see how I access the control.

How should I use this control (or any control that I just want to call functions on without having the control as a visible object)?

Regards,

-Tim

Dead men don't spam.

Dmitriy
August 24th, 1999, 06:17 PM
When you create ActiveX, or any COM object, it returns to you pointer to IUnknown interface.
From this you can call function IUnknown::QueryInterface(), that will return pointer to interface you want, if exist. Usually, this interface has some special function you want to use.
For example, call pointer to you interface Add5() and from there call you function you've been developed.
After use ActiveX, call Release() function.
Good source about it is TN038 from MSDN and book "Inside OLE".


Dmitriy, MCSE

Tom Carlson
September 21st, 1999, 01:15 PM
Once the control is dropped on your form, you can use Class Wizard to add a member variable from which you can then call the controls methods. Just go to the Member Variables tab, and find your control's ID and add it like you'd add any other control.