"wrong" application icon in dialog based application
-
Hi everyone When I use Visual C++ 6 to build a Doc/View application the final application will have an icon it its title bar. This icon is 16 x 16 pixel and looks exactly as the corresponding 16 x 16 pixel version of the icon I can edit in the resource editor. On the other side when I build a dialog based application it will have an icon in its title bar, too, it is 16 x 16 pixel in size, too, but it does not look the same as the icon I can edit in the resource editor. I guess it is "shrunken" from the 32 x 32 pixel version of the icon in the resource editor, nevertheless it is not what I want because this "shrunken" icon looks distorted. A screenshot demonstrating this behaviour: http://www.teeteehaa.de/pictures/applicationicon.gif Can anbody explain me the reason for this and how to prevent it? Thanks, Matthias "T.T.H." Grobe
-
Hi everyone When I use Visual C++ 6 to build a Doc/View application the final application will have an icon it its title bar. This icon is 16 x 16 pixel and looks exactly as the corresponding 16 x 16 pixel version of the icon I can edit in the resource editor. On the other side when I build a dialog based application it will have an icon in its title bar, too, it is 16 x 16 pixel in size, too, but it does not look the same as the icon I can edit in the resource editor. I guess it is "shrunken" from the 32 x 32 pixel version of the icon in the resource editor, nevertheless it is not what I want because this "shrunken" icon looks distorted. A screenshot demonstrating this behaviour: http://www.teeteehaa.de/pictures/applicationicon.gif Can anbody explain me the reason for this and how to prevent it? Thanks, Matthias "T.T.H." Grobe
-
Hi everyone When I use Visual C++ 6 to build a Doc/View application the final application will have an icon it its title bar. This icon is 16 x 16 pixel and looks exactly as the corresponding 16 x 16 pixel version of the icon I can edit in the resource editor. On the other side when I build a dialog based application it will have an icon in its title bar, too, it is 16 x 16 pixel in size, too, but it does not look the same as the icon I can edit in the resource editor. I guess it is "shrunken" from the 32 x 32 pixel version of the icon in the resource editor, nevertheless it is not what I want because this "shrunken" icon looks distorted. A screenshot demonstrating this behaviour: http://www.teeteehaa.de/pictures/applicationicon.gif Can anbody explain me the reason for this and how to prevent it? Thanks, Matthias "T.T.H." Grobe
It may be the 16x16 vs. 32x32 thing that's ailing you.
-
Hi everyone When I use Visual C++ 6 to build a Doc/View application the final application will have an icon it its title bar. This icon is 16 x 16 pixel and looks exactly as the corresponding 16 x 16 pixel version of the icon I can edit in the resource editor. On the other side when I build a dialog based application it will have an icon in its title bar, too, it is 16 x 16 pixel in size, too, but it does not look the same as the icon I can edit in the resource editor. I guess it is "shrunken" from the 32 x 32 pixel version of the icon in the resource editor, nevertheless it is not what I want because this "shrunken" icon looks distorted. A screenshot demonstrating this behaviour: http://www.teeteehaa.de/pictures/applicationicon.gif Can anbody explain me the reason for this and how to prevent it? Thanks, Matthias "T.T.H." Grobe
This is because CWinApp::LoadIcon will only load the large 32 x 32 pixel icon, and when you call CWnd::SetIcon(m_hIcon, FALSE), the SetIcon() function will shrink the 32 x 32 icon to 16 x 16. The fix is to add another icon member to your dialog class to hold the small icon, use LoadImage() to load it, and set that as your small icon
class CMyDialog : public CDialog
{
protected:
HICON m_hIcon;
HICON m_hSmallIcon;
...
};CMyDialog::CMyDialog(...
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_hSmallIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON,
16, 16,
LR_DEFAULTCOLOR);
...
}BOOL CMyDialog::OnInitDialog()
{
...
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hSmallIcon, FALSE); // Set small icon
...
}
[
](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!
-
This is because CWinApp::LoadIcon will only load the large 32 x 32 pixel icon, and when you call CWnd::SetIcon(m_hIcon, FALSE), the SetIcon() function will shrink the 32 x 32 icon to 16 x 16. The fix is to add another icon member to your dialog class to hold the small icon, use LoadImage() to load it, and set that as your small icon
class CMyDialog : public CDialog
{
protected:
HICON m_hIcon;
HICON m_hSmallIcon;
...
};CMyDialog::CMyDialog(...
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_hSmallIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON,
16, 16,
LR_DEFAULTCOLOR);
...
}BOOL CMyDialog::OnInitDialog()
{
...
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hSmallIcon, FALSE); // Set small icon
...
}
[
](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!