Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CMFCButton Icon twice as big as it should be

Posted on 2008-09-18
3
Medium Priority
?
2,132 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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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.
Suggested Courses

810 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