Microsoft foundation classes are pretty much the stuff of high level languages, all documentation is pretty much based on Visual Studio and the MFC wizards, most of the useful helper functions are C++ source contained in header files. DISP interfaces appear difficult to work with and COM in general scares assembly people. However in its finite wisdom, Microsoft has the ATL, the Active Template Library that encapsulates MFC objects and allows those of us who use assembler to incorporate them into our applications. To create an ATL object is fairly simple, just initialize the library then use CreateWindowEx. From there it makes a shallow dive into COM, in the following example we must get the IUnknown interface from the control in order to query for IWebBrowser2 which is the COM interface that controls the WebBrowser MFC class. With that interface we can do just about anything we want with our browser, display pages, move forward or back etc... It gets a bit more complicated with Event Sinks, COM by itself has very little to no functionality when it comes to an object notifying its host of events, so Microsoft introduced DISP, which allows the object to notify your application if something happens. The difference is subtle but significant, with a DISP interface, you write the interface and the object calls it through IDispatch using a predefined dispatch ID for each event. To write a DISP interface you need to implement the IUnknown and IDispatch interfaces in your application then pass a pointer to the object via AtlAdvise. For IUnknown you have to implement all three methods, for IDispatch only Invoke is called but you should also implement at least the default handler for GetIDsOfNames according to Microsoft.
The following is an example of an ATL based web browser with an event sink. You will have to download my latest header files to assemble it using GoAsm, for MASM users I doubt that there is a set of includes for ATL but translating the applicable GoAsm headers shouldn't a huge task.
The following is an example of an ATL based web browser with an event sink. You will have to download my latest header files to assemble it using GoAsm, for MASM users I doubt that there is a set of includes for ATL but translating the applicable GoAsm headers shouldn't a huge task.
Hi Donkey
Thanks for sharing your work, which is a valuable reference.
Biterider
Thanks for sharing your work, which is a valuable reference.
Biterider