WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
Click here for larger image
Environment: VC6, Windows 98, 2000, NT4
Often programmers meet situations when it is necessary to filter data based on a number of criteria. A solution is to implement a number of simple combos or checklist boxes. This has the disadvantage of not allowing multiple choices (combos) or taking a lot of space (checklist boxes).
I saw on CodeGuru other ideas, which are more or less close to what I expected from such a control but I think they lack functionality in a way or another, so I decided to write my own solution.
User keys: alt + up or down, F4 (to drop/close the dropdown) up, down (to move the selection up or down), right (to expand current item), left (to collapse current item) and space (to check or uncheck the current item).
Using CCheckComboBox: For example if you want to add 3 countries: "USA" (ID=5), "Canada" (ID=6), "UK" (ID=7), and their corresponding continents, you would have to write the following code:
//## ADD tree items: m_choCountries.AddString("North America"); m_choCountries.AddString("USA", 5, ROOT_LEVEL + 2); m_choCountries.AddString("Canada", 6, ROOT_LEVEL + 2); m_choCountries.AddString("Europe"); m_choCountries.AddString("UK", 7, ROOT_LEVEL + 2); //## CHECK all items m_choCountries.CheckAll(TRUE); //## UNCHECK the item with ID = 6 m_choCountries.SetCheck(6, FALSE); //## GET all checked items CString strCheckedItems = m_choCountries.GetCheckedIDs();