Click here to Skip to main content
12,956,197 members (101,710 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked
Posted 25 Aug 2014

A Tiny Custom List Control

, 25 Aug 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
A tiny custom list control

Download demo

Download CustomListCtrl.rar



We can insert a listbox:

We can even insert a dialog:

Using the Code

Create Custom List Control

m_pListCtrl = new CListCtrlCustom();
m_pListCtrl->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, rcListCtrl, this, IDC_STATIC_RECT+1);

The custom list control contains all the CListCtrl's methods.

Its Extended Methods

//Get extended control
// If the grid has no control, return NULL
CWnd *GetCtrl(int nRow, int nCol);

//Get text normal
// If the grid has no control, return CListCtrl::GetItemText.Or return CWnd::GetWindowText
CString GetText(int nRow, int nCol);

//Add any control to the grid

BOOL SetItemEx(int nItem, int nSubItem, CWnd *pExCtrl);

//Set the row height

BOOL SetRowHeight(int nHeight);

//Register the rectangle setting event

void RegOnSettingRect(LPFUNC_RESIZE_CTRL pfnResizeExCtrl);

The Rectangle Setting Event Callback Function

//return TRUE, that means control rectangle has been set. 
//Return FALSE, the control will be fill to the grid.
	(CListCtrlCustom *pListCtrl, CWnd *pCtrl, CRect &rectGrid);


  1. The control that will be inserted into the custom list control must set its parent to the custom list control.
  2. The dialog to be inserted must be set to child style.

Points of Interest

The way I set the row height is not the best way. Can you help me to improve it? See CListCtrlCustom::SetRowHeight(...).

Thanks for reading.


  • 2015/4/20 - Fixed some bugs and made a special control example


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer China Telecom Guangdong
China China
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
skyformat99@gmail.com28-Aug-14 15:46
memberskyformat99@gmail.com28-Aug-14 15:46 
GeneralMy vote of 5 Pin
xiayingang27-Aug-14 22:18
memberxiayingang27-Aug-14 22:18 
Generalvery good, come on Pin
xiayingang26-Aug-14 18:59
memberxiayingang26-Aug-14 18:59 
General同为china的支持一哈 ,例子浅显易懂 Pin
hohogpb26-Aug-14 4:34
memberhohogpb26-Aug-14 4:34 
AnswerRe: 同为china的支持一哈 ,例子浅显易懂 Pin
HateCoding26-Aug-14 4:55
memberHateCoding26-Aug-14 4:55 
QuestionImage and Source Code Link Missing Pin
syed shanu25-Aug-14 20:10
membersyed shanu25-Aug-14 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 26 Aug 2014
Article Copyright 2014 by HateCoding
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid