views:

297

answers:

1

I have an ActiveX component which contains a control (webbrowser control embedded in composite control dialog pane) for accessing certain URL. The ActiveX component accessing URL can be used in other MFC or VB projects. The usage is to register the ActiveX component (use regsvr32 cmd) and then insert the control in a dialog window by using "Insert ActiveX control".

Now I am planning to convert the ActiveX component to static library with the same browser window and web access functions. I wonder how to do it? In addition, how the browser window (in static library) can be used in other MFC projects. Is it through functions call? Is there a sample project available?

I used Microsoft .Net 2003 as development tool.

Thank you very much in advance.

A: 

I'm a little unclear about the extent to which you think you can put all of that in a static library.

This is probably not going to be as straightfoward as you think. The wizard and code in VS/MFC/ATL which allows you to insert an ActiveX control in a dialog is doing a lot of work for you. That said, it makes certain assumptions about the nature of the site for the ActiveX control, such as how the message pump works, who is the owner window, the threading model, and so on. In a dialog, these are knowns. In another context, they are not.

The right way to go about doing what you're doing is to leave it as an ActiveX control. Maybe if you stated what problem you are trying to solve by putting it into a static library, we could give other options.

The WebBrowser ActiveX control is really a wrapper for the shdocvw.dll library, in the system32 folder. shdocvw.dll is the heart and soul of IE (and, by extension, much of the Windows Explorer interface). It's all very heavily based on COM, which has its own rules for loading libraries and so on. So the site (any application which wants to use your ActiveX control) really needs to be friendly to ActiveX/COM anyway.

Alan McBee
Thanks Alan! The reason I want to convert ActiveX into static library is customer requirement. Some of our customers do not want to include separate DLL file in the package. The want to build the browser control we provide into their code, e.g MFC or ATL projects. Is there any other way to achieve this goal?
bionicoder
You should be able to create a MFC/ATL static library which hosts the shdocvw WebBrowser. This will mean some custom coding on your part--the ATL/MFC project wizards only build DLLs which host COM controls. See http://msdn.microsoft.com/en-us/library/1stby863(VS.71).aspx for info on hosting ActiveX from ATL. shdocvw WebBrowser can not be made into a static library, for the reasons I mentioned above (installed as a core component of IE).
Alan McBee