Click here to Skip to main content
13,254,754 members (55,177 online)
Click here to Skip to main content


43 bookmarked
Posted 17 Dec 2002

An extended ListBox control

, 17 Dec 2002
A control that offers extensible entry specification and full keyboard support.
#if !defined(AFX_LISTBOXEX_H__E503C832_836A_11D5_AD87_8686F2D82715__INCLUDED_)
#define AFX_LISTBOXEX_H__E503C832_836A_11D5_AD87_8686F2D82715__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// ListBoxEx.h : header file
#define NO_BMP_ITEM 0
#define BLANK_BMP 1

#define SC_UP 2 //Up scroll
#define SC_DOWN 3 //Down Scroll

#define SC_NORMAL NULL //Normal scroll
#define SC_PRESSED DFCS_PUSHED //The scroll is pressed
#define SC_DISABLED DFCS_INACTIVE //The scroll is disabled
// CListBoxEx window

class CListBoxEx : public CListBox
// Construction

// Attributes

// Operations

// Overrides
	// ClassWizard generated virtual function overrides
	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	virtual void PreSubclassWindow();

// Implementation
	void SetBMPSize(int Height, int Width);
	void SetTextColor(COLORREF crTextColor, COLORREF crHighlight);
	void InsertItem(int nIndex, UINT nID, LPCTSTR lpszText);
	void AddItem(UINT IconID, LPCTSTR lpszText);
	void SetItemHeight (int newHeight);
	virtual ~CListBoxEx();
	void SetBkColor( COLORREF crBkColor, COLORREF crSelectedColor=GetSysColor(COLOR_HIGHLIGHT));
	// Generated message map functions
	void DrawScrolls(UINT WhichOne,UINT State);
	void DrawBorders();
	BOOL m_bOver;
	short m_ItemHeight; //Height of each item
	COLORREF m_crTextHlt; //Color of the text when highlighted
	COLORREF m_crTextClr; //Color of the text
	COLORREF m_HBkColor; //Color of the highlighted item background
	int m_BmpWidth; //Width of the bitmap
	int m_BmpHeight; //Height of the bitmap

	CBrush m_BkBrush;
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
	afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
	afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
	afx_msg void OnNcPaint();
	afx_msg UINT OnNcHitTest(CPoint point);
	afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnEnable(BOOL bEnable);


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

#endif // !defined(AFX_LISTBOXEX_H__E503C832_836A_11D5_AD87_8686F2D82715__INCLUDED_)

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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 18 Dec 2002
Article Copyright 2002 by ClearlyDotNet
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid