Click here to Skip to main content
15,883,838 members
Articles / Desktop Programming / MFC

CIconDialog - Selecting Icons

Rate me:
Please Sign up or sign in to vote.
4.79/5 (28 votes)
28 Mar 2004CPOL3 min read 134.3K   5.7K   54  
The CIconDialog class allows you to add an icon-selection dialog box to your applications
/* 
DESCRIPTION:
	CIconDialog  - Icon Selection Dialog Class

NOTES:
	Copyright(C) Armen Hakobyan, 2002
	mailto:armenh@cit.am

	Undocumented SelectIcon APIs by Henk Devos
	Article _T("How to display the Pick Icon Dialog") :)
	http://www.codeproject.com/shell/selecticon.asp
	
VERSION HISTORY:
	09 Mar 2002 - First release
*/

#pragma once

BOOL
SelectIconW (
	HWND   hWndParent, 
	LPWSTR lpszFilename, 
	DWORD  dwBufferSize, 
	DWORD* pdwIndex
	);

BOOL
SelectIconA (
	HWND   hWndParent, 
	LPSTR  lpszFilename, 
	DWORD  dwBufferSize, 
	DWORD* pdwIndex
	);

#ifdef UNICODE
#define SelectIcon SelectIconW
#else
#define SelectIcon SelectIconA
#endif

// CIconDialog
#include "afxdlgs.h"

class CIconDialog : public CCommonDialog
{
	DECLARE_DYNAMIC(CIconDialog)

public:	
	CIconDialog(LPCTSTR lpszIconFile = NULL,
				DWORD dwIconIndex = NULL,
				CWnd* pParentWnd = NULL);
	virtual ~CIconDialog();

public:
	virtual int			DoModal(void);

	AFX_INLINE HICON	GetIconHandle(void) const;
	AFX_INLINE UINT_PTR	GetIconCount(void) const;
	AFX_INLINE DWORD	GetIconIndex(void) const;
	AFX_INLINE LPCTSTR	GetIconFile(void) const;	

protected:
	TCHAR		m_szIconFile[_MAX_FNAME];
	DWORD		m_dwIconIndex;
	HICON		m_hIconHandle;
	UINT_PTR	m_uIconCount;	

protected:
	DECLARE_MESSAGE_MAP()
};

AFX_INLINE LPCTSTR CIconDialog::GetIconFile(void) const
	{ return m_szIconFile; }

AFX_INLINE DWORD CIconDialog::GetIconIndex(void) const
	{ return m_dwIconIndex; }

AFX_INLINE UINT_PTR CIconDialog::GetIconCount(void) const
	{ return m_uIconCount; }

AFX_INLINE HICON CIconDialog::GetIconHandle(void) const
	{ return ::DuplicateIcon(AfxGetInstanceHandle(), m_hIconHandle); }

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 Code Project Open License (CPOL)


Written By
Software Developer (Senior) SafeNet Inc
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions