Click here to Skip to main content
15,891,033 members
Articles / Desktop Programming / MFC

Group Combo Box

Rate me:
Please Sign up or sign in to vote.
5.00/5 (20 votes)
19 Nov 2013Zlib18 min read 105.8K   8.6K   68  
Easily extensible owner-drawn combo box with items grouping and sorting
/* 
 *  Filename:    TestDlg.h
 *  Description: Group Combo Box demo dialog
 *  Copyright:   Julijan Sribar, 2012-2013
 *
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the author(s) be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 3. This notice may not be removed or altered from any source distribution.
 */

#pragma once
#include "GroupComboBox.h"
#include "FontGroupComboBox.h"
#include "GroupComboBoxWithIcons.h"
#include "afxwin.h"


// CTestDlg dialog
class CTestDlg : public CDialogEx
{
// Construction
public:
	CTestDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_TESTAPPLICATION_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

public:
	afx_msg void OnBnClickedButtonAddRecentOdFixed();
	afx_msg void OnBnClickedButtonRemoveRecentOdFixed();
	afx_msg void OnBnClickedButtonAddRecentOdVariable();
	afx_msg void OnBnClickedButtonRemoveRecentOdVariable();
	afx_msg void OnBnClickedAutowidthComboOdFixed();
	afx_msg void OnBnClickedAutowidthComboOdVariable();
	afx_msg void OnBnClickedAutocompleteComboOdFixed();
	afx_msg void OnBnClickedAutocompleteComboOdVariable();
	afx_msg void OnBnClickedCancelwescapeComboOdFixed();
	afx_msg void OnBnClickedCancelwescComboOdVariable();

private:
	CComboBox m_comboBox;
	CGroupComboBox m_comboBoxODFixed;
	CFontGroupComboBox m_comboBoxODFixed2;
	CFontGroupComboBoxVariable m_comboBoxODVariable;
	CGroupComboBoxWithIcons m_comboCountries;
	CButton m_autowidthComboODFixed;
	CButton m_autowidthComboODVariable;
	CButton m_autocompleteComboODFixed;
	CButton m_autocompleteComboODVariable;
	CButton m_undoByEscComboODFixed;
	CButton m_undoByEscComboODVariable;
	CImageList m_fontTypes;

	void FillOrdinaryComboBox();
	void FillODFixedComboBox();
	void FillODVariableComboBox();
	void FillComboBoxCountries();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License


Written By
Software Developer (Senior)
Croatia Croatia
Graduated at the Faculty of Electrical Engineering and Computing, University of Zagreb (Croatia) and received M.Sc. degree in electronics. For several years he was research and lecturing assistant in the fields of solid state electronics and electronic circuits, published several scientific and professional papers, as well as a book "Physics of Semiconductor Devices - Solved Problems with Theory" (in Croatian).
During that work he gained interest in C++ programming language and have co-written "C++ Demystified" (in Croatian), 1st edition published in 1997, 2nd in 2001, 3rd in 2010, 4th in 2014.
After book publication, completely switched to software development, programming mostly in C++ and in C#.
In 2016 coauthored the book "Python for Curious" (in Croatian).

Comments and Discussions