|
|
Title |
How to Load Small Icons
|
Summary |
When creating a Dialog based application the default implementation loads a 32x32 icon and compresses it to 16x16 for display in the title bar. |
Contributor |
John McTainsh
|
Published |
5-Sep-2000 |
Last updated |
5-Sep-2000 |
|
|
Description.
The reason the 32x32 icon is loaded is because constructor's call
to
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
only loads the 32x32 icon resource.
Solution.
To load the correct 16x16 resource
LoadImage must be called as shown below.
/////////////////////////////////////////////////////////////////////////////
// CDlgSyntaxColourHtml message handlers
BOOL CDlgSyntaxColourHtml::OnInitDialog()
{
TRACE( _T("CDlgSyntaxColourHtml::OnInitDialog()\n") );
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
HICON hIcon = (HICON)LoadImage(
AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON, 16, 16, LR_SHARED );
ASSERT( hIcon );
SetIcon( hIcon, FALSE ); // Set Small icon
|