How to create ActiveX control supporting Automation
Posted on 1997-09-25
I have created a basic ActiveX control using MSVC++ 5.0 Control Wizard. I added one arbitrary method, and compiled it.
When I use the control in VB 5.0, it works as long as I place the control on the form and access its method that way. But if I use automation, such as in the following VB code,
Dim obj as Object
set obj = CreateObject("MyControl.mycontrol.1")
I get the error:
Run-time error -2147418113 (8000ffff)
Method 'MyMethod' of object '_DMyControl' failed.
(The error number is S_UNEXPECTED in VC++, and it occurs because the m_bInitialized member variable is false in the instance of COleControl - I tried the equivalent of "CreateObject" in VC++ and the I got the same error)
There must be something simple that I am missing out on...I thank you in advance for any help.
(FYI, the CreateObject statement seems to function properly, as I do get a pointer to my control when debugging)
PS: Instead of trying to instantiate the other object using "CreateObject" (or the equivalent set of C++ functions), can one get a pointer to an ActiveX control from within another ActiveX control given that they both reside in the same container???