[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

CMFCButton Icon twice as big as it should be

Posted on 2008-09-18
3
Medium Priority
?
2,207 Views
Last Modified: 2013-12-14
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
Comment
Question by:tg_wilk
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
Naveen_R earned 2000 total points
ID: 22517869
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
 
LVL 7

Author Comment

by:tg_wilk
ID: 22530898
Worked like a charm. I wonder what was wrong with the other one.
0
 
LVL 3

Expert Comment

by:Naveen_R
ID: 22534880
LoadIcon loads the icon in the size of SM_CXICON and SM_CYICON system metric values..
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question