Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Internet Explorer AdBlock

, 17 Jan 2008
Internet Explorer AdBlock Add-on
ieadblock_src.zip
IE AdBlockPS
IE AdBlockps.def
IE AdBlock
AdBlockBand.rgs
AdBlockBHO.rgs
bin
XListCtrlSSDU.lib
XListCtrlSSRU.lib
IE AdBlock.def
IE AdBlock.rgs
res
bmpToolbar.bmp
checkboxes.bmp
icoSettings.ico
XListCtrl
checkboxes.bmp
// Redefinition protection
#ifndef ADBLOCKBHO_H
#define ADBLOCKBHO_H

//*********************************************************************
// INCLUDES
//*********************************************************************

#include "resource.h"       // main symbols

#include "IEAdBlock.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

//*********************************************************************
// CAdBlockBHO
//*********************************************************************

class ATL_NO_VTABLE CAdBlockBHO :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CAdBlockBHO, &CLSID_AdBlockBHO>,
	public IObjectWithSiteImpl<CAdBlockBHO>,
	public IDispatchImpl<IAdBlockBHO, &IID_IAdBlockBHO, &LIBID_IEAdBlockLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
	public IDispEventImpl<1, CAdBlockBHO, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1>
{
public:
	// Declarations
	DECLARE_REGISTRY_RESOURCEID(IDR_ADBLOCKBHO)

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	DECLARE_NOT_AGGREGATABLE(CAdBlockBHO)

	BEGIN_COM_MAP(CAdBlockBHO)
		COM_INTERFACE_ENTRY(IAdBlockBHO)
		COM_INTERFACE_ENTRY(IDispatch)
		COM_INTERFACE_ENTRY(IObjectWithSite)
	END_COM_MAP()

	BEGIN_SINK_MAP(CAdBlockBHO)
		SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete)
		SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNavigate2)
	END_SINK_MAP()

	// Constructor & destructor
	CAdBlockBHO();

	// Functions
	HRESULT FinalConstruct();
	void FinalRelease();

	STDMETHOD (SetSite) (IUnknown*);

	void STDMETHODCALLTYPE OnDocumentComplete(IDispatch *pDisp, VARIANT *pvarURL);
	void STDMETHODCALLTYPE OnBeforeNavigate2(IDispatch *pDisp, VARIANT *pvarURL, short flags,
		VARIANT *pvarTarget, VARIANT *pvarPost, VARIANT *pvarHeaders, VARIANT *pvarCancel);

private:
	// Functions
	HRESULT Initialize(IUnknown * pUnkSite);
	void	DeInitialize();
	void	SyncNewestLists();
	void	SpeedUpCache();
	void	RemoveAdvertisement(IHTMLDocument2 * pDocument);
	void	SetStatus(CString sStatus);

	// Variables
	CComPtr<IWebBrowser2> m_spWebBrowser;
	bool		m_fAdvised;
	CSettings * m_pSettings;
	CPath	  * m_pPath;
	CListData * m_pListData;
	int			m_iSpeedUpCacheTimer;
};

OBJECT_ENTRY_AUTO(__uuidof(AdBlockBHO), CAdBlockBHO)

// End of redefinition protection
#endif // ADBLOCKBHO_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

Geert van Horrik
Software Developer CatenaLogic
Netherlands Netherlands
I am Geert van Horrik, and I have studied Computer Science in the Netherlands.
 
I love to write software using .NET (especially the combination of WPF and C#). I am also the lead developer of Catel, an open-source application development framework for WPF, Silverlight, WP7 and WinRT with the focus on MVVM.
 
I have my own company since January 1st 2007, called CatenaLogic. This company develops commercial and non-commercial software.
 
To download (or buy) applications I have written, visit my website: http://www.catenalogic.com
Follow on   Twitter

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 17 Jan 2008
Article Copyright 2008 by Geert van Horrik
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid