How to catch certain browsing events

Hi everyone,
i'm currently developing a BHO with ATL as i'm in need to write an application that would record the interaction between a user and the browser while surfing the internet.
With my BHO i'm able to get notification of the events thanks to the DIID_DWebBrowserEvents2 interface. This way i can record when new windows are opened, a page is navigated to, a print template is istantiated and so on.
But this just takes care of half of the events i'd like to catch. What i'd like to record too is when a user presses the back, forward and refresh button, saves a page or the content of a link, adds a bookmark, and similar. I can't get notifications of those events from the DWebBrowserEvents2 interface.
How could i manage in getting this information? (Someone told me about "subclassing the IE standard toolbar" to intercept the WM_COMMANDS messages from the buttons hosted in the toolbar; is it a good and straightforward way to do it?)
I already know C++, but i'm not used to write code dealing with MS tecnologies, so beside giving me a few tips to answer my question if you could even point me to some code snippets would be largely appreciated!

Thanks in advice to everyone who will gave his/her input!
Regards,

Davide Magistri

[1287 byte] By [DavideMagistri] at [2008-2-15]
# 1
Here are the DHTML methods. http://msdn.microsoft.com/workshop/author/dhtml/reference/methods.asp

As a specific example, the "back" functionality is described here: http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/back.asp

Hope that aims you in the right direction.

William

WilliamPHenryJr at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 2
The seminal article on BHO is at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebgen/html/bho.asp?frame=true&hidetoc=true

In it you'll find this:

To intercept the events fired by the browser, the BHO needs to connect to it via an IConnectionPoint interface and pass the IDispatch table of the functions that will handle the various events. The pointer to IConnectionPointContainer obtained previously is used to call the FindConnectionPoint method that returns a pointer to the connection point object for the required outgoing interface: in this case, DIID_DWebBrowserEvents2. The following code shows how the connection takes place:

HRESULT CViewSource::Connect(void)
{
HRESULT hr;
CComPtr<IConnectionPoint> spCP;

// Receives the connection point for WebBrowser events
hr = m_spCPC->FindConnectionPoint(DIID_DWebBrowserEvents2, &spCP);
if (FAILED(hr))
return hr;

// Pass our event handlers to the container. Each time an event occurs
// the container will invoke the functions of the IDispatch interface
// we implemented.
hr = spCP->Advise( reinterpret_cast<IDispatch*>(this), &m_dwCookie);
return hr;
}
(it goes on...)

Good luck,
William

WilliamPHenryJr at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 3

Hi William,

thank you very much for your input, even if what i'd like to do is slightly different

I do already use the DWebBrowserEvents2 interface to intercept the events fired by the browser (the DOCUMENT_COMPLETE, DOWNLOAD_BEGIN, NEW_WINDOW3, etc...), but this does not let me know about almost all the events i'm actually interested in. I mean i'd like to be notified when the user goes back and forward surfing the history, saves pages or downloads files, saves bookmarks, ... and stuff like that.

I mean it is very simple doing it in Mozilla (the system lets you know about anything that's happening just by implementing the usual publish-subscribe architectural style), but it becomes more complex in IE.

Well, I managed in completing my project anyway: I decided to get these events directly from the Internet Explorer Standard Toolbar, subclassing the ReBarWindow32 in the IE windows hierarchy. With this workaround i get the notifications of these events just by intercepting the WM_COMMAND message flow between the ToolbarWindow32 and the ReBarWindow32.

I think i'll use the same technique (subclassing) to work my way to intercept the rest of the events i need.

Anyway thank you very much for your input, i really appreciated that you tried to answer my question twice!

Keep up the good work,

Davide

DavideMagistri at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 4
Hi William,
thank you very much for your input, even if what i'd like to do is slightly different

I do already use the DWebBrowserEvents2 interface to intercept the events fired by the browser (the DOCUMENT_COMPLETE, DOWNLOAD_BEGIN, NEW_WINDOW3, etc...), but this does not let me know about almost all the events i'm actually interested in. I mean i'd like to be notified when the user goes back and forward surfing the history, saves pages or downloads files, saves bookmarks, ... and stuff like that.

I mean it is very simple doing it in Mozilla (the system lets you know about anything that's happening just by implementing the usual publish-subscribe architectural style), but it becomes more complex in IE.

Well, I managed in completing my project anyway: I decided to get these events directly from the Internet Explorer Standard Toolbar, subclassing the ReBarWindow32 in the IE windows hierarchy. With this workaround i get the notifications of these events just by intercepting the WM_COMMAND message flow between the ToolbarWindow32 and the ReBarWindow32.

I think i'll use the same technique (subclassing) to work my way to intercept the rest of the events i need.

Anyway thank you very much for your input, i really appreciated that you tried to answer my question twice!


Keep up the good work,

Davide
DavideMagistri at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...