This control enhances the classic
CComboBox control, and puts in its dropdown list a
CListCtrl, with all benefits that come after: drop down list could have multicolumn, checkboxes, ordering, etc.
This control is related with this one: CTreeComboBox, the difference consists only in control that is encapsulated in the dropdown list.
Using the Code
In order to be used, this control must have 3 classes:
CListComboBox, derived from
CComboListCtrl, derived from
CYourComboListCtrl, derived from
CYourComboListCtrl is only a customization of your
CListCtrl that you want to use, but it must be derived from
CComboListCtrl in order to have the applied functionality.
So, if you want this control hybrid, you just have to include 6 files, ListComboBox.h and cpp, ComboListCtrl.h and cpp, and an extension of
CComboListCtrl, let's say MyComboListCtrl.h and cpp.
Once you have these files in your project, you can easily use this control just like this:
CComboBox control on your form, but it must be type of
m_pListCtrl2 = new CMyComboListCtrl;
And after that, you just handle your
m_pListCtrl2 as you want (configurating, populate with data, etc.)
You cand find more details in the attached sample project.
combobox has several methods that help in using this hybrid control:
DisplayList() - Use this instead of native
ShowDopDown() in order to show drop down menu
SetEditText(SetEditText(LPCTSTR lpszString) - To setup a text for edit
GetEditItemData - To setup an
itemdata for selected item, visible from
SetListCtrl(CComboListCtrl* pListCtrl) - is setting the
CComboListCtrl object as drop down list
IsControlActive() - Retrieve the state of drop down list
GetDroppedHeight() - Return the width and height of drop down list
SetDroppedHeight() - Setup the width and height of drop down list
GetEditTooltip() - Set/get the tooltip for edit
combobox, that could be different than edit text
SetShowTooltip() - Activate / deactivate the tooltip for edit
SetShowEditTooltipOverItem() - Set / Get the position of tooltip for edit
combobox, to be shown over edit area, of above
Of course, there is another method available on this
CComboBox that makes from this control a good choice for situations when you need an enhanced
I hope it helps you! P.S.
As far as I can, I will come back with new details about using this control.
- 2016-09-23- Article published