
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