Hi Everyone
I have written some code to manipulate DOM for IE browser. It uses ATL library to create COM. The DOM is by default manipulated OnDocumentComplete where more information is added to each link on the webpage. But I would like to insert a hotkey ctrl+alt+M. On pressing the hotkey the DOM needs to be manipulated. I am not too sure how to go about it. Below I have pasted my code:

DOMBHO.h

#pragma once
#include "resource.h" // main symbols

#include "DOM.h"
#include <shlguid.h>
#include <exdispid.h> // DISPID_DOCUMENTCOMPLETE, etc.
#include <mshtml.h>

#include "resource.h"



#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif




class ATL_NO_VTABLE CDOMBHO :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CDOMBHO, &CLSID_DOMBHO>,
public IObjectWithSiteImpl<CDOMBHO>,
public IDispatchImpl<IDOMBHO, &IID_IDOMBHO, &LIBID_DOMLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public IDispEventImpl<1, CDOMBHO, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1>


{
private:
CComPtr<IWebBrowser2> m_spWebBrowser;
private:
BOOL m_fAdvised;
private:
void RemoveImages(IHTMLDocument2 *pDocument);
private:
BSTR xgenerate(BSTR outURL);





public:
CDOMBHO()
{
}





STDMETHOD(SetSite)(IUnknown *pUnkSite);
DECLARE_REGISTRY_RESOURCEID(IDR_DOMBHO)

DECLARE_NOT_AGGREGATABLE(CDOMBHO)

BEGIN_COM_MAP(CDOMBHO)
COM_INTERFACE_ENTRY(IDOMBHO)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IObjectWithSite)
END_COM_MAP()

BEGIN_SINK_MAP(CDOMBHO)
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete)
END_SINK_MAP()


void STDMETHODCALLTYPE OnDocumentComplete(IDispatch *pDisp, VARIANT *pvarURL);

DECLARE_PROTECT_FINAL_CONSTRUCT()

HRESULT FinalConstruct()
{
return S_OK;
}

void FinalRelease()
{
}

public:

};

OBJECT_ENTRY_AUTO(__uuidof(DOMBHO), CDOMBHO)






DOMBHO.cpp


STDMETHODIMP CDOMBHO::SetSite(IUnknown* pUnkSite)
{


if (pUnkSite != NULL )
{
// Cache the pointer to IWebBrowser2.
HRESULT hr = pUnkSite->QueryInterface(IID_IWebBrowser2, (void **)&m_spWebBrowser);
if (SUCCEEDED(hr))
{
// Register to sink events from DWebBrowserEvents2.
hr = DispEventAdvise(m_spWebBrowser);
if (SUCCEEDED(hr))
{
m_fAdvised = TRUE;
}
}
}
else
{
// Unregister event sink.
if (m_fAdvised)
{
DispEventUnadvise(m_spWebBrowser);
m_fAdvised = FALSE;
}

// Release cached pointers and other resources here.
m_spWebBrowser.Release();
}




// Call base class implementation.

return IObjectWithSiteImpl<CDOMBHO>::SetSite(pUnkSite);
}



// I want the web browser to display the pages normally and only on pressing hotkey i want it to manipulate the dom


void STDMETHODCALLTYPE CDOMBHO::OnDocumentComplete(IDispatch *pDisp, VARIANT *pvarURL)
{
HRESULT hr = S_OK;


// Query for the IWebBrowser2 interface.
CComQIPtr<IWebBrowser2> spTempWebBrowser = pDisp;

// Is this event associated with the top-level browser?
if (spTempWebBrowser && m_spWebBrowser &&
m_spWebBrowser.IsEqualObject(spTempWebBrowser))
{
// Get the current document object from browser...
CComPtr<IDispatch> spDispDoc;
hr = m_spWebBrowser->get_Document(&spDispDoc);
if (SUCCEEDED(hr))
{
// ...and query for an HTML document.
CComQIPtr<IHTMLDocument2> spHTMLDoc = spDispDoc;
if (spHTMLDoc != NULL)
{
// Finally, remove the images.



RemoveImages(spHTMLDoc);
}
}
}
}