ComboBox with Tree Dropdown

Environment:VC6, Win200, ME (has not test on other OS)

Using the Class

  1. Just as you normally would, place a ComboBox on the dialog. And name it m_comboBoxFolder.
  2. Add the files ComboBoxFolder.cpp, ComboBoxFolder.h, TreeCtrlFolder.cpp, TreeCtrlFolder.h, Folder.cpp and Folder.h to your project.
  3. Import the bitmap files folder0.bmp and give them resource Ids of "IDB_FOLDER".
  4. In the header file for the dialog, add an include for ComboBoxFolder.h at the top. Manually change variable from CComboBox m_comboBoxFolder; in step 1 to CComboBoxFolder m_comboBoxFolder;
  5. In the dialog's OnInitDialog() function, call m_comboBoxFolder.Init(0, 300) for setting dropped width and height of a tree dropdown.
  • To add path to tree-dropped-down call:
  • m_comboBoxFolder.AddPath("C:\\Windows\\temp");
    
  • Whenever a user selects an item in the tree-dropped-down, a message, WM_SELECTITEM_CHANGE, will be sent to Dialog: A small demo below shows how to catch the message and get parameter has been passed.
    ON_MESSAGE(WM_SELECTITEM_CHANGE, OnSelectItemChange)
    
    long CTestDlg::OnSelectItemChange(WPARAM w, LPARAM l)
    { CString path = "";
     CFolder* folder = (CFolder*) w;
     if (folder != NULL)
       path = folder->m_path;
    
     return 0;
    }
  • To get path selected in the tree-dropped-down call:
    m_comboBoxFolder.GetSelectedPath()
    
I haven't added too much here insofar as explanation of code because the code is included and very easy to understand.


Downloads

Comments

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

Top White Papers and Webcasts

  • While virtual desktop infrastructure (VDI) comes with many potential advantages, adoption of VDI has been slow. The reality is that the path to achieving the VDI promise land is a difficult one, mostly due to high expense, poor end-user experience, and management difficulties. More often than not, the root cause of all three of these failure modes is storage. This white paper explores how a new, 100%-flash based approach to VDI can overcome the key VDI failure traps and deliver a VDI solution that both …

  • Live Event Date: July 22, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT In this WhatWorks analysis, John Pescatore examines a use case where end users had local administrative rights on their PCs and it had gotten out of hand for this Fortune 500 Energy and Utilities company. The compelling event that prompted the company to reexamine this situation was the migration to Windows 7. In Windows XP, a custom tool that allowed users one of three levels of administrative rights to their workstations would need to be …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds