embed an VC++6.0 ActiveX in a VC++.net Application 
Author Message
 embed an VC++6.0 ActiveX in a VC++.net Application

Hello alltogether,

I now tried for a long time to embed an VC++6.0 ActiveX file in an VC++.net
MFC Application. But it always failed.
I first tried the following way, which works:

Menue "Projects" -> "Add existing Item", add file  "ADwinControl.idl "
(In  "ClassView" appear two classes ADWINCONTROLLib und
ICADwin.)
At the beginning of the Code import ActiveX Type Library through "#import"
and include "using namespace ADWINCONTROLLib;" to be able to access the
functions of the ActiveX

Quote:
>#import "Z:\\ADwinControl.TLB"
>using namespace ADWINCONTROLLib;

To access the functions and properties I created a smart pointer.

Quote:
>void CMFC_App_axDlg::OnBnClickedButton1()
>{

>      CoInitialize( NULL );

>      //Use a smart pointer (sp = smartpointer)

>      ICADwinPtr spADwin(__uuidof(ADwin));

>      spADwin->DeviceNo = 16;

>      spADwin->Boot("c:\\adwin\\adwin9.btl");

>      //free Smart Pointer

>      spADwin=NULL;

>      CoUninitialize();

>}

I tried to read everything about it, but I couldn't find an easier way,
which works.

I for example tried the following way:

Solution Explorer, Add, Add Existing Item, select "ADwinControl.idl ".
solution Explorer Add , Add Class, "MFC Class From TypeLib",then the "Add
Class From TypelibWizard" opens. I selected the TypeLib from "Available type
libraries" and selected the interfaces.
I wrote the following code:
ICADwin *padwin;

padwin = new ICADwin;

padwin->DeviceNo = 16;

padwin->Boot("c:\\adwin\\adwin9.btl");

and got the following
errors:z:\Karolin\TEST\ax_einbinden_unmanaged_c++\ax_einbinden_unmanaged_c++
Dlg.cpp(142): error C2065: 'ICADwin' : undeclared identifier
z:\Karolin\TEST\ax_einbinden_unmanaged_c++\ax_einbinden_unmanaged_c++Dlg.cpp
(142): error C2065: 'padwin' : undeclared identifier
z:\Karolin\TEST\ax_einbinden_unmanaged_c++\ax_einbinden_unmanaged_c++Dlg.cpp
(142): error C2296: '*' : illegal, left operand has type ''unknown-type''
z:\Karolin\TEST\ax_einbinden_unmanaged_c++\ax_einbinden_unmanaged_c++Dlg.cpp
(142): error C2297: '*' : illegal, right operand has type ''unknown-type''
z:\Karolin\TEST\ax_einbinden_unmanaged_c++\ax_einbinden_unmanaged_c++Dlg.cpp
(143): error C2061: syntax error : identifier 'ICADwin'
z:\Karolin\TEST\ax_einbinden_unmanaged_c++\ax_einbinden_unmanaged_c++Dlg.cpp
(144): error C2227: left of '->Boot' must point to class/struct/union

then I put
#using <ADWINCONTROLLib>

in my code and got the following error

z:\Karolin\TEST\ax_einbinden_unmanaged_c++\ax_einbinden_unmanaged_c++Dlg.cpp
(12): fatal error C1190: managed targeted code requires '#using
<mscorlib.dll>' and '/clr' option

then I put
#using <mscorlib.dll>
to my code and changed PropertyPage->C/C++->General -> Compile As Managed to
"Assembly Support ( /clr)"

and got the error:
ax_einbinden_unmanaged_c++ Command line error D2016 : '/RTC1' and '/clr'
command-line options are incompatible
...

Another way was:
solution Explorer Add , Add Class, "MFC Class From TypeLib",then the "Add
Class From TypelibWizard" opens. I selected the TypeLib from "Available type
libraries" and selected the interfaces.

I wrote the following code:
CCADwin *padwin;
padwin = new CCADwin;

//padwin->DeviceNo = 16;

padwin->Boot("c:\\adwin\\adwin9.btl");

I could comile without errors, but could not access my properties ( e.g.
DeviceNo). CCADwin only contains the functions.

Can anybody help me? please!!

Karolin

- Show quoted text -



Fri, 11 Feb 2005 17:21:33 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Upgrading VC 6.0 custom appwizard application to VC .NET

2. Challenge/Help VB.NET VC++.NET VC++6.0

3. Slower compilation with VC Net 2003 (7.1) when compared to VC Net 7.0

4. vc to embedded vc

5. Embedded MySQL / VC.NET 2003 / MFC

6. Newbie Q: vc.atl vs vc.activex.templatelib

7. upgrade of dll from vc++ 6.0 to vc++.net

8. VC.net or VC?

9. VC/VC.NET/STL

10. VC or VC.net after C++?

11. Incremental linker bug in VC++6/SP5 and VC++.NET

12. VC before VC.NET?

 

 
Powered by phpBB® Forum Software