Dropdown list of choices for items in CTreeCtrl and CListCtrl

Environment: VC6

Derived classes from CTreeCtrl and CListCtrl with dropdown list of choices for items text (combo box)

Derived classes from CListCtrl and CTreeCtrl allows user to open a list of choices for item's text. Double click or F4 keyboard button on item opens pre created list of strings. Useful when it's necessary to create a visual editable protocol trees and lists of fields (values must be one of the values from dropdown list, or may be entered by user).

It's very simple to use. Just follow steps below.

1. Create a new control by VC6 resource editor and specify a variable of CTreeCtrlEx (CListCtrlEx) type for that control or use Create() functions for dynamic creation of that controls.

2. Use InsertItemWithComboBox() function to insert a new item into control.

3. Use InsertComboBoxString() function to insert a new entry for item's combo box. Item must already created by InsertItemWithComboBox() function.

4. Use SetComboDroppedHeight() function to specify height for dropdown combo box. Can be used at runtime. (No multithreading support and will not effect on any already visible combo boxes).

5. Use SetComboMinMaxWidths() function to specify minimum and maximum widths for all combo boxes in control. Can be used at runtime. (No multithreading support and will not effect on any already visible combo boxes).

Here is the partial interface for CListCtrlEx class (interface for CTreeCtrlEx is almost the same):

class EXCTRLSDDLEXP CListCtrlEx : public CListCtrl
{
	typedef CMap< int, int, CWnd*, CWnd* > mapItemToCB;
. . .
. . .
. . .
public:
  void  SetComboDroppedHeight( int iNewHeight );
  void  SetComboMinMaxWidths( UINT iNewMinWidth = 150, 
                              UINT iNewMaxWidth = UINT_MAX );
  int   InsertItemWithComboBox( LPCTSTR lpszItem, 
                                BOOL bEditableCombo );
  void  RemoveComboBox( int nItemRemoveFrom );
  void  RemoveAllComboBoxes();
  int   InsertComboBoxString( int nItemInsertTo, 
                              LPCTSTR lpszItem, 
                              int iIndex = -1 );
  BOOL  DeleteItem( int nItem );
  BOOL  DeleteAllItems();

. . .
. . .
. . .

};

Downloads

Download sources and demo project - 18,664 bytes


Comments

  • dropdownlist

    Posted by Legacy on 06/05/2003 12:00am

    Originally posted by: Rajesh kumar Prajapati

    that is realy best thing,can u give some time for my problem for parsing text file and display the related data in the dropdown when we type the message in richtext box.
    

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

  • With JRebel, developers get to see their code changes immediately, fine-tune their code with incremental changes, debug, explore and deploy their code with ease (both locally and remotely), and ultimately spend more time coding instead of waiting for the dreaded application redeploy to finish. Every time a developer tests a code change it takes minutes to build and deploy the application. JRebel keeps the app server running at all times, so testing is instantaneous and interactive.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds