Simon Green
October 1st, 1999, 07:10 AM
N.B. I believe this is a VB question despite the many references to VC.
1/. I have only 1 monthes experience in VB, a passing knowledge of COM and a couple of years experience in VC++ and the MFC.
2/. I have inherited an OLE control (OCX) initially developed using the VC++ V5.0 MFC ActiveX ControlWizard.
3/. The control has been migrated to VC++ V6.0.
4/. The MFC ActiveX ControlWizard implemented late binding dispatch and event interfaces.
5/. I have added a custom interface, i.e. early binding interface, as described in the MSDN article "TN038: MFC/OLE IUnknown Implementation".
The aim of the new interface was to provide additional functionality without modifying the existing interfaces, i.e. it is a requirement of COM that interfaces do not change once they are defined.
(I am aware that what I am attempting to achieve may be an example of bad design.)
All the interfaces must refer to the same instance of the OLE control, because the OLE control contains state information.
In other words the new custom interface methods will only work correctly if they have access to state information held within the OLE object.
6/. The typelibrary information is incorportated in the OLE control.
7/. I make use the OLE component in a VB V5.0 project by placing it on a form.
This makes all the properties, methods and events implemented by the late binding dispatch and event interfaces available for use.
VB appears to have access to the type library information contained within the OLE control at this point.
8/. I wish to use the methods implemented by the custom interface.
9/. I have refered to the MSDN, the Microsoft knowledge base, etc without success.
10/. I have experimented with VB code, an example of which is listed below, again without success.
Dim NewCustomInterface as INewCustomInterface
set NewCustomInterface = NameOfOLEControlOnForm 'Fails at this point because objects are the wrong type
11/. I have succeeded in doing the following in VC++ V6.0 and I do not understand why I can not do the same in VB V5.0.
a/. I have added the OLE control to a dialogue.
The OLE control becomes a member variable of the dialogue class.
b/. I have used the GetControlUnknown() function to obtain a reference to the IUnknown interface.
c/. I have used QueryInterface() to obtain a reference to the new custom interface.
d/. I have then called a method on the new custom interface.
Any suggestions please.
1/. I have only 1 monthes experience in VB, a passing knowledge of COM and a couple of years experience in VC++ and the MFC.
2/. I have inherited an OLE control (OCX) initially developed using the VC++ V5.0 MFC ActiveX ControlWizard.
3/. The control has been migrated to VC++ V6.0.
4/. The MFC ActiveX ControlWizard implemented late binding dispatch and event interfaces.
5/. I have added a custom interface, i.e. early binding interface, as described in the MSDN article "TN038: MFC/OLE IUnknown Implementation".
The aim of the new interface was to provide additional functionality without modifying the existing interfaces, i.e. it is a requirement of COM that interfaces do not change once they are defined.
(I am aware that what I am attempting to achieve may be an example of bad design.)
All the interfaces must refer to the same instance of the OLE control, because the OLE control contains state information.
In other words the new custom interface methods will only work correctly if they have access to state information held within the OLE object.
6/. The typelibrary information is incorportated in the OLE control.
7/. I make use the OLE component in a VB V5.0 project by placing it on a form.
This makes all the properties, methods and events implemented by the late binding dispatch and event interfaces available for use.
VB appears to have access to the type library information contained within the OLE control at this point.
8/. I wish to use the methods implemented by the custom interface.
9/. I have refered to the MSDN, the Microsoft knowledge base, etc without success.
10/. I have experimented with VB code, an example of which is listed below, again without success.
Dim NewCustomInterface as INewCustomInterface
set NewCustomInterface = NameOfOLEControlOnForm 'Fails at this point because objects are the wrong type
11/. I have succeeded in doing the following in VC++ V6.0 and I do not understand why I can not do the same in VB V5.0.
a/. I have added the OLE control to a dialogue.
The OLE control becomes a member variable of the dialogue class.
b/. I have used the GetControlUnknown() function to obtain a reference to the IUnknown interface.
c/. I have used QueryInterface() to obtain a reference to the new custom interface.
d/. I have then called a method on the new custom interface.
Any suggestions please.