ComboBox with Tree Dropdown
Posted
by Hai Ha
on March 19th, 2001
Environment:VC6, Win200, ME (has not test on other OS)
Using the Class
- Just as you normally would, place a ComboBox on the dialog. And name it m_comboBoxFolder.
- Add the files ComboBoxFolder.cpp, ComboBoxFolder.h, TreeCtrlFolder.cpp, TreeCtrlFolder.h, Folder.cpp and Folder.h to your project.
- Import the bitmap files folder0.bmp and give them resource Ids of "IDB_FOLDER".
- 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;
- 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");
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;
}
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.

Comments