IconComboBox v1.08

Welcome to lconComboBox, 3 simple MFC classes to provide icon selection combo boxes.

An example of what the classes look like is shown below:

IconComboBox example

 

 

Features
Copyright
Usage
History
API Reference
Contacting the Author

 

 

 

Features

 

 

 

Copyright

 

 

 

Usage

 

 

 

History

v1.08 (14 April 2022)

v1.07 (4 May 2020)

v1.06 (15 March 2020)

v1.05 (22 December 2019)

v1.04 (2 June 2019)

v1.03 (24 December 2018)

v1.02 (29 December 2016)

v1.01 (12 September 1998)

v1.0 (5 August 1998)

 

 

 

API Reference

The API consists of the the base class CIconComboBox and two derived classes CSmallIconComboBox and CLargeIconComboBox. The two derived class provide support for SM_CXSMICON / SM_CYSMICON and SM_CXICON / SM_CYICON sized icons respectively.

This base class implements a combo box to allow selection of any sized icons. CIconComboBox provides the following public members:

AddIcon
DeleteIcon
InsertIcon
GetCurSelIcon
SetCurSelIcon
SetIconSize
SetUseSmallIconSize
SetUseLargeIconSize
GetIconXSize
GetIconYSize

and the global functions:

DDX_CBIcon

 

 

CIconComboBox::AddIcon

int AddIcon(UINT nResourceID, HINSTANCE hInstance = AfxGetResourceHandle());

int AddIcon(LPCTSTR pszResourceID, HINSTANCE hInstance = AfxGetResourceHandle());

Return Value

it is the zero-based index of the icon just inserted in the combo box. CB_ERR is returned upon error.

Parameters

nResourceID / pszResourceID Resource ID of the icon to add to the combo box.

hInstance instance handle to load the icon from.

Remarks

Adds a icon to the end of the combo box.

 

CIconComboBox::DeleteIcon

int DeleteIcon(int nIndex);

Return Value

If the return value is greater than or equal to 0, then it is a count of the icons remaining in the list. CB_ERR is returned upon error.

Parameters

nIndex Specifies the index of the icon that is to be deleted.

Remarks

Deletes a icon in the list box of an icon combo box.

 

CIconComboBox::InsertIcon

int InsertIcon(int nIndex, UINT nResourceID, HINSTANCE hInstance = AfxGetResourceHandle());

int InsertIcon(int nIndex, LPCTSTR pszResourceID, HINSTANCE hInstance = AfxGetResourceHandle());

Return Value

it is the zero-based index of the icon just inserted in the combo box. CB_ERR is returned upon error.

Parameters

nIndex Contains the zero-based index to the position in the list box that will receive the string. If this parameter is –1, the string is added to the end of the list.

nResourceID / pszResourceID Resource ID of the icon to add to the combo box.

hInstance instance handle to load the icon from.

Remarks

Adds an icon at a specific offset to the combo box.

 

CIconComboBox::GetCurSelIcon

UINT GetCurSelIconAsInt() const;

LPCTSTR GetCurSelIcon() const;

Remarks

Returns the Icon ID of the currently selected combo box item.

 

CIconComboBox::SetCurSelIcon

void SetCurSelIcon(UINT nResourceID);

void SetCurSelIcon(LPCTSTR pszResourceID);

Parameters

nIconID / pszResourceID Resource ID of the icon of the combo box item which should be selected.

Remarks

Sets the selection of the combo box to the item which has the specified icon ID.

 

CIconComboBox::SetIconSize

void SetIconSize(int nCX, int nCY);

Parameters

nCX The width of the icons to show in the combo box.

nCY The height of the icons to show in the combo box

Remarks

Allows you to specify the size of icons to show in the combo box.

 

CIconComboBox::SetUseSmallIconSize

void SetUseSmallIconSize();

Remarks

Helper method which simply calls SetIconSize with the values returned from GetSystemMetrics(SM_CXSMICON) & GetSystemMetrics(SM_CYSMICON).

 

CIconComboBox::SetUseLargeIconSize

void SetUseLargeIconSize();

Remarks

Helper method which simply calls SetIconSize with the values returned from GetSystemMetrics(SM_CXICON) & GetSystemMetrics(SM_CYICON).

 

CIconComboBox::GetIconXSize

int GetIconXSize();

Return Value

The width of the icons currently being shown by the combo box.

 

CIconComboBox::GetIconYSize

int GetIconYSize();

Return Value

The height of the icons currently being shown by the combo box.

 

DDX_CBIcon

void DDX_CBIcon(CDataExchange* pDX, int nIDC, UINT& nResourceID);

void DDX_CBIcon(CDataExchange* pDX, int nIDC, LPCTSTR& pszResourceID);

Remarks

Standard MFC DDX function to set / get the Icon ID from the combo box. Both CSmallIconComboBox and CLargeIconComboBox will work with this function.

 

 

 

Contacting the Author

PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
14 April 2022