Edit ListBox control

Edit ListBox control

This article was submitted .

The Edit ListBox control is a subclassed STATIC (label) Windows control that behaves like a listbox but adds a header with a couple of navigation buttons and an optional browse button when it's in edit-mode.

The text in the original label control is used as header text. It is also possible to remove the up/down navigation buttons. The control has several methods allowing you to query and set the list data.

You can use the window style EDLS_BROWSE to include a browse button when in the edit mode. The control sends an EDLN_BROWSE notification when the button is clicked. Other notifications include EDLN_ITEMCHANGING and EDLN_ITEMCHANGED.
To change the edit text while in edit mode, grab the edit control using GetEditCtrl() and change the window text using SetWindowText().

The released files comprise a bitmap, which must be given the Resource ID IDB_EDITLISTBOX ! This bitmap defines the button images.

There is also an improved version available by Ludvig A. Norin. It contains some fixes to the original WTL CBitmapButton control as well.

How to use it

To use it, place a label control on your dialog.
Add a member variable to your dialog implementation file...
CEditListBox m_ctlList
In the OnInitDialog() event handler, add the following line:
LRESULT OnInitDialog(UINT /*uMsg*/, 
                     WPARAM /*wParam*/, 
                     LPARAM /*lParam*/, 
                     BOOL& /*bHandled*/)

Source Code Dependencies

Microsoft Visual C++ 6.0
Microsoft WTL 3.0 Library

Download Files

DownloadSource Code (6 Kb)
Improved version by Ludvig A. Norin (8 Kb)

To the top