Win32 WebBrowser ActiveX Control

Add the WebBrowser ActiveX control to any window using standard Win32 function calls. The WebBrowser ActiveX control is the heart of Microsoft Internet Explorer and is used by many applications to provide HTML support. There exists a Mozilla ActiveX control which can be used instead as a direct replacement for the WebBrowser ActiveX control, even using the same API. (Note: A tool is provided at the Mozilla ActiveX control project website which will allow you to modify a binary which uses the WebBrowser ActiveX control to use the Mozilla ActiveX control instead.)

My first step was to figure out how to link to the atl.dll library. This was quite a task considering my limited knowledge of DLL’s. Follow the DLL instructions, then edit the .def file that you have created. I knew that I needed to call AtlAxWinInit(void);, so I had to add “@0” (the 0 tells us that there are zero arguments sent to this function) to make that work. Finish building the import library and add it to your project. You must repeat this process for every call that you will make to the DLL.

Next, you must borrow the code from atldef.h (under #if define(_ATL_DLL)) to define ATLAPI and ATLAPI_(x). One or more of those may not be needed, but they were grouped so I added them all. At the beginning of your program, you need to call AtlAxWinInit(); Since I did not have the header file, I used the code declaration given by MSDN and that worked fine.

Ok, this got to the point where I couldn’t figure out what to do next and I didn’t have much time left. Create a window as a child window of another window as in the following:
hwnd = CreateWindowEx( WS_EX_CLIENTEDGE,
"AtlAxWin",
"https://www.calcmaster.net/",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
hwndParent,   GetModuleHandle(NULL),   // retrieves the current hInstance
NULL);

With this you may browse the Internet, but I have not yet figured out how to use standard Win32 calls (or even AtlAx* calls) to manage the component. (This is because I am not using MSVC but instead gcc.) This means that you can’t monitor anything, or change the web page within your code (though clicking on links works), or do anything really useful. This component would only work well as a help file viewer or something like that. If anyone else can figure out how to get more functionality out of this, please contact me.

References
http://support.microsoft.com/kb/q192560/
http://www.arstdesign.com/articles/Win32_dialoghelpers.html
http://www.iol.ie/~locka/mozilla/control.htm

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *