Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CMFCButton Icon twice as big as it should be

Posted on 2008-09-18
3
Medium Priority
?
2,071 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

618 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