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
// XHeaderCtrl.h  Version 1.5
//
// Author:  Hans Dietrich
//          hdietrich@gmail.com
//
// License:
//     This software is released into the public domain.  You are free to use
//     it in any way you like, except that you may not sell this source code.
//
//     This software is provided "as is" with no expressed or implied warranty.
//     I accept no liability for any damage or loss of business that this 
//     software may cause.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef XHEADERCTRL_H
#define XHEADERCTRL_H

#include "XCheckbox.h"
#include "XListCtrlLibDefs.h"

#define DT_DEFAULT	((UINT)-1)		//+++

#define FLATHEADER_TEXT_MAX	80

#define FH_PROPERTY_SPACING			1
#define FH_PROPERTY_ARROW			2
#define FH_PROPERTY_STATICBORDER	3
#define FH_PROPERTY_DONTDROPCURSOR	4
#define FH_PROPERTY_DROPTARGET		5

///////////////////////////////////////////////////////////////////////////////
// CXHeaderCtrl data
struct XHEADERCTRLDATA
{
	// ctor
	XHEADERCTRLDATA()
	{
		pCheckbox       = NULL;
		crText          = (DWORD) -1;
		bAllowUserInput = TRUE;
	}

	// dtor
	virtual ~XHEADERCTRLDATA()
	{
		if (pCheckbox)
			delete pCheckbox;
		pCheckbox = NULL;
	}

	CXCheckbox *	pCheckbox;				// pointer to CXCheckbox object
	COLORREF		crText;
	BOOL			bAllowUserInput;		// TRUE = normal state;  FALSE = user input
											// actions will be ignored
};

///////////////////////////////////////////////////////////////////////////////
// CXHeaderCtrl class
class XLISTCTRLLIBDLLEXPORT CXHeaderCtrl : public CHeaderCtrl
{
    DECLARE_DYNCREATE(CXHeaderCtrl)

// Construction
public:
	CXHeaderCtrl();
	virtual ~CXHeaderCtrl();

// Attributes
public:
	int			ColumnHitTest(CPoint point);
	BOOL		DeleteColumn(int nCol);
	BOOL		DeleteItem(int nCol);
	void		EnableDividerLines(BOOL bEnable) { m_bDividerLines = bEnable; }
	UINT		GetAlignment() { return m_nFormat; }
	BOOL		GetAllowUserInput(int nCol);
	int			GetCheck(int nCol);
	BOOL		GetDividerLines() { return m_bDividerLines; }
	COLORREF	GetItemColor(int nCol);
	int			GetSpacing() { return m_nSpacing; }
	COLORREF	GetTextColor() { return m_crText; }
	void		InsertColumn(int nCol, int nCheckboxState);
	int			InsertItem(int nPos, HDITEM* phdi);
	BOOL		ModifyProperty(WPARAM wParam, LPARAM lParam);
	void		SetAlignment(UINT nFormat) { m_nFormat = nFormat; }
	BOOL		SetAllowUserInput(int nCol, BOOL bAllowUserInput);
	void		SetCheck(int nCol, int nCheckedState);
	BOOL		SetItemColor(int nCol, COLORREF crText);
	void		SetListCtrl(CListCtrl *pListCtrl) { m_pListCtrl = pListCtrl; }
	void		SetSpacing(int nSpacing) { m_nSpacing = nSpacing; }

// Overrides
public:
	virtual void DrawItem(int nCol,
						  CDC *pDC,
						  COLORREF crText,
						  COLORREF crBkgnd,
						  CRect& rect,
						  HDITEM& hditem);
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CXHeaderCtrl)
	//}}AFX_VIRTUAL

// Implementation
protected:
	static HTHEME	m_hThemeHeader;
	int				m_nCurrentHot;
	CListCtrl *		m_pListCtrl;
	UINT			m_nFormat;
	COLORREF		m_crText;				// this is global text color;  you
											// can set each column individually
	BOOL			m_bMouseInWindow;
	BOOL			m_bDividerLines;
	BOOL			m_bStaticBorder;
	int				m_nSpacing;
	SIZE			m_sizeImage;
	SIZE			m_sizeArrow;
	UINT			m_nDontDropCursor;
	UINT			m_nClickFlags;
	CPoint			m_ptClickPoint;
	CPtrArray		m_ColumnData;
	BOOL			m_bAllowUserInput;		// TRUE = normal;  FALSE = all user
											// input for checkboxes will be ignored;
											// this is global flag; you can set
											// each column individually
	int				m_nCurrentCheckboxItem;

	COLORREF		m_cr3DHighLight;
	COLORREF		m_cr3DShadow;
	COLORREF		m_cr3DFace;
	COLORREF		m_crBtnText;

	int DrawBitmap(CDC* pDC, CRect rect, HDITEM hditem, CBitmap* pBitmap, 
		BITMAP* pBitmapInfo, BOOL bRight);
	int DrawHeaderText(int nCol, CDC* pDC, COLORREF crText, COLORREF crBkgnd, CRect rect, HDITEM hditem);
	void ProcessMouseOverCheckbox(int nItem, CPoint point);
	BOOL PtInCheckboxRect(int nItem, CPoint point);
	void ResetCurrentCheckbox();
	void UpdateItem(int nItem);

// Generated message map functions
protected:
	//{{AFX_MSG(CXHeaderCtrl)
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnSysColorChange();
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnTimer(UINT nIDEvent);
	//}}AFX_MSG
	afx_msg LRESULT OnLayout(WPARAM wparam, LPARAM lparam);
	afx_msg LRESULT OnSetImageList(WPARAM wparam, LPARAM lparam);
	afx_msg LRESULT OnMouseLeave(WPARAM, LPARAM);

	DECLARE_MESSAGE_MAP()
};

///////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif //XHEADERCTRL_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)

Share

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
Web04 | 2.8.140827.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