Re: Replace a VB ocx using a new MFC ocx



Thanks Alexander.

I am using the IDL from the VB6 control in my MFC ActiveX now.
I've got one question:

The MFC ActiveX control is called C_MFC. The interface MFC wizard created is
called _DC_MFC. Normally, I can add method to this interface on Class View in
IDE. It will automatically add the method to a class called CC_MFCCtrl. Then
I can just modify the implementation of the method in the CC_MFCCtrl.cpp
file. I am not sure if this CC_MFCCtrl class implements interface _DC_MFC,
but I found code like "InitializeIIDs(&IID_DC_MFC, &IID_DC_MFCEvents)" in
CC_MFCCtrl class constructor.

Now, I've removed _DC_MFC interface from the control. But how can I
associate the new interface XXX_Control with the CC_MFCCtrl class? For all
the method defined in XXX_Control interface, I will implement them in
CC_MFCCtrl class. But what else do I need to do?

Thank you very much!



"Alexander Nickolov" wrote:

You should get rid of that interface the MFC wizard created
for you and implement the interface the VB6 control implements
(XXX_Control according to your post). You can copy/paste it
into your IDL (ODL?) file from the OleView IDL source view
of the VB6 control's type library.

Now, the next problem to solve is persistence. Unfortunately,
I don't know of any documentation how VB6 controls persist
their data in binary form. You may have to reverse-engineer
it. If the client is under your control I'd advise you to simply
regenerate the persistent state and recompile it (for example
remove and re-add the control on its form/dialog).

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"Yu" <Yu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5E64E96F-2A30-4E8C-BBD1-04C1D18E71F3@xxxxxxxxxxxxxxxx
Thanks for your reply. Sorry for lack of information, here is more
description of this problem:

I use the OLE/COM Object Viewer in VS2003 to view the VB control. The
interface it supports are:
IConnectionPointContainer, IdataObject, IDispatch, IOleContainer,
IOleContol, IOleInPlaceActiveObject, IOleInPlaceFrame, IOleInPlaceObject,
IOleInPlaceUIWindow, IOleObject, IOleWindow, IParseDisplayName,
IPerPropertyBrowsing, IPersist, IPersistPropertyBag, IPersistStorage,
IPersistStreamInit, IProvideClassInfo, IQuickActivate, IServiceProvider,
ISpecifyPropertyPages, ISupportErrorInfo, IUnknown, IViewObject,
IViewObject2,
and another interace called XXX_Control(same name as the ocx)

Description of Problem:

1. I've got the VB ocx file called A.ocx, and a compiled application
called
B.exe, which uses A.ocx. When B.exe is running, I can press a button to
invoke a method called TestMethod(in string, out ret long) in A.ocx.

2. I build a MFC control called C_MFC.ocx, the VS IDE generated a
interface
called _DC_MFC for me. I added TestMethod to this interface.

3. In the C_MFC project, I modify C_MFC.idl, C_MFC.cpp and C_MFCCtrl.cpp
files to change the CLSID, TypeLib ID, and ProgID to the same as A.ocx
control.

4. Unregister A.ocx, register C_MFC.ocx.

5. Run B.exe. It starts up ok, but when I click the button to call
TestMethod(), it pops up a box saying "can't can find member".

I've also tried to use ATL ActiveX control instead of MFC ActiveX control.
But this time the B.exe application doesn't even start. I debug into the
mfc
source code. It shows that when the application starts, it called
PersistStreamInit::Load to load a image. (I guess it should be the image
ofocx control). But this call failed.

Thank you very much!



"Alexander Nickolov" wrote:

What interface do you expose? This would only work with
a pure dispinterface. Otherwise you must make sure your
new object implements the same interface the old one did.
FYI VB6 creates dual interfaces for its objects.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"Yu" <Yu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:203A2CF6-B007-4E20-A558-17D0B0EF605D@xxxxxxxxxxxxxxxx
Hi,

We released a VB ocx to a customer 2 months ago, and they used this ocx
in
their VC application. Now we are releasing new MFC ocx, but the
customer
doesn't want to recompile their application.

So I made the new MFC ocx same clsid as the old VB ocx, and also the
same
progID. I ask the customer to unregister their old VB ocx and register
this
new MFC ocx. I presume their application will call the method in the
new
MFC
ocx using same clsid.(all the method format are same in both ocx). But
it
doesn't work. It seems like the application can not find the right
member
method.

Could you guys please help with this?

Thanks a lot









.