Abhinav Jha

Hi,

I am stuck. Please tell me how to use a MFC ActiveX control from inside a gadget, when I don't have the DLL of it ( since there's no template in VS to create a MFC activeX control DLL ) . How can I use it in my gadget then I went through the earlier examples and they were either concerned with VB or the DLL version of the ActiveX.

I created a MFC ActiveX control ( using a standard VS template ) . The name of the project is "MyActiveX" and the name of the class ( to which I added a method to return a CString ) is "MyActiveXCtrl"

CString CMyActiveXCtrl:Tongue Tiedtringprint(){

CString string1;

string1=_T("Hello world");

return string1;

}

( The above is the function that I added to the class ).

I compiled the above program and there were no errors reported. ( This also means that VS registered the ocx files )

Now, I tried creating an object using

var myControl=new ActiveXObject("MyActiveX.MyActiveXCtrl");

However, the above line gives the error " Automation server can't create object " , when I try to run the Html file in the sidebar or in the browser.

What am I doing wrong here And how can I correct it Please help.




Re: Sidebar Gadget Development How to use a c++/MFC ActiveX control in a sidebar gadget ?

Jonathan Abbott

Your Class isn't visible to COM, have you turned on COM Interop

On the Solution Properties, click on the Assembly Information button on the Application tab. Ensure Make assembly COM-Visible is ticked.

There's a few examples on here for various languages, if you need more detail.






Re: Sidebar Gadget Development How to use a c++/MFC ActiveX control in a sidebar gadget ?

Abhinav Jha

Dear Jonathan,

Thanks a lot, but I'm pretty sure I have COM interop on, since the same is working if i use an ATL project instead of an ActiveX control. Does VS automatically turn on COM interop for one and off for the other ( ActiveX control ) Also, I could not find any of the tabs you mentioned above in solution properties !! I am using Visual studio 2005 ( 8.0.50727-8600).






Re: Sidebar Gadget Development How to use a c++/MFC ActiveX control in a sidebar gadget ?

Jonathan Abbott

COM Interop is off by default.

Sorry, try the Project properties, not the solution. Project\<project> Properties from the menu.