• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2337
  • Last Modified:

CMFCButton Icon twice as big as it should be

I'm trying to put an icon on a button in MFC (VC++ 2008). To do this I use CMFCButton class for a control variable. It has SetImage method for this (code snippet  below).
The icon is displayed on the button but it is twice as big as the original. The ico file has only one icon 16x16 32bpp but it is displayed as 32x32 - you can see the pixels. They were 32x32 but I resized them to 16x16.
I tried Clean for the project, Rebuild as well. I deleted the icons from the resource and added them anew. Nothing helps.

What else can I do?
HICON hAddIcon =  pApp->LoadIcon(IDI_ADD);
 
	m_btnNowyMat.SetImage(hAddIcon);

Open in new window

0
tg_wilk
Asked:
tg_wilk
  • 2
1 Solution
 
Naveen_RCommented:
Tru using the LoadImage() function intead of LoadIcon().


HICON hIcon = (HICON)::LoadImage( AfxGetInstanceHandle(), 
                                  MAKEINTRESOURCE(IDI_ADD),
                                  IMAGE_ICON,
                                  16,16, 0 );

Open in new window

0
 
tg_wilkAuthor Commented:
Worked like a charm. I wonder what was wrong with the other one.
0
 
Naveen_RCommented:
LoadIcon loads the icon in the size of SM_CXICON and SM_CYICON system metric values..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now