Home Search Contact us About us
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
Page rating   87% for 11 votes Useless Brilliant


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.


To load the correct 16x16 resource LoadImage must be called as shown below.

// CDlgSyntaxColourHtml message handlers
BOOL CDlgSyntaxColourHtml::OnInitDialog()
    TRACE( _T("CDlgSyntaxColourHtml::OnInitDialog()\n") );

    // 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(
                IMAGE_ICON, 16, 16, LR_SHARED );
    ASSERT( hIcon );
    SetIcon( hIcon, FALSE );        // Set Small icon
Comments Date
Home Search Contact us About us