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

x
?
Solved

transparent icons have black background

Posted on 2004-10-14
1
Medium Priority
?
1,041 Views
Last Modified: 2013-11-20
Hi Experts,

I'm creating a toolbar control with custom icons.  The problem I have is that the icons have a black background when I want transparency instead.  

The icon I'm using:
The icon was created using adobe illustrator plus axialis icon workshop.  The icon is available in many different sizes/color depths, and the colors look ok except for the black-instead-of-transparent background.  When I use the icon on my WinXP desktop, it looks fine with proper transparency.  You can see my icon file at http://amis.sf.net/temp/arrow.ico.

Dev environment:
MSVC 6 running on WinXP
Project is an MFC exe, SDI, with CFrameWnd derived main window.  The code below is executed in the window's OnCreate function.

Here are the steps I've taken:


///////////////begin code///////////////////////////////////////////////
//the path to the icon file
CString szIconFile("c:\\docs\\arrow.ico");

//the image list (i've also tried the ILC_COLOR8 flag instead)
m_tb1_images.Create(24,24,ILC_COLOR24,4,4);

//create an icon resource
HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(IDR_ICON),RT_GROUP_ICON);

//load the icon from file
HICON hIcon = (HICON)LoadImage(hInst,szIconFile,IMAGE_ICON,24,24,
            LR_LOADFROMFILE);

//add the icon to the image list
m_tb1_images.Add(hIcon);

//create the toolbar (it's a CToolBarCtrl object)
m_tb1.Create(WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT, rect, this, ID_TOOLBAR);

//set the image list
m_tb1.SetImageList(&m_tb1_images);

//add a string to the toolbar
m_tb1.AddString(IDS_OPEN);


//button structure(s)
TBBUTTON buttons[1];

buttons[0].iBitmap = 0;
buttons[0].idCommand = ID_CMD_OPEN;
buttons[0].fsState = TBSTATE_ENABLED;
buttons[0].fsStyle =  TBSTYLE_BUTTON;
buttons[0].iString = 0;

//add a button to the toolbar
m_tb1.AddButtons(1, &buttons[0]);

//auto size the toolbar
m_tb1.AutoSize();

///////////////end code///////////////////////////////////////////////

Thanks
Marisa
0
Comment
Question by:marisademeglio
[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
1 Comment
 
LVL 3

Accepted Solution

by:
_mb_ earned 500 total points
ID: 12316408
It should work with the ILC_MASK Flag for the image list:
m_tb1_images.Create(24, 24, ILC_COLOR24 | ILC_MASK, 4, 4);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

597 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