Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 6th, 2008, 2:24 PM   #1
Syndication
Newbie
 
Join Date: Jan 2008
Posts: 3
Rep Power: 0 Syndication is on a distinguished road
[C++] Transparent toolbar bitmap.

Hello,

I'm using VS [C++] 2008 Express (no MFC). I've been trying all day to get a toolbar onto my app that uses a .bmp file for the icons. The code I've used to do this is:

// Load toolbar bitmap. (48 pixel wide, 16 high)
HBITMAP hbmTool = (HBITMAP)LoadImage(g_mainhInstance, "tool.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS);
  
// blah blah, setup buttons..

HWND hWnd = CreateToolbarEx(g_mainWinHandle, WS_CHILD | WS_VISIBLE, IDTB_MAIN,  3, NULL, (UINT)hbmTool, tbButtons,              
3, 16, 16, 16, 16, sizeof(TBBUTTON));

This works OK, but for the fact that the background part of the tool.bmp that is supposed to be transparent is showing as white.

I've literally been googling this problem all day trying to find out how I resolve this to the point I now have a headache. X( I realise I need to be using TransparentBlt and/or BitBlt. I had no luck with TransparentBlt, but this is as far as I've got using BitBlt:

 HBITMAP hbmTool = (HBITMAP)LoadImage(g_mainhInstance, "tool2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS);
HDC hdcTool, hdcNew;
hdcTool = CreateCompatibleDC(0);
SelectBitmap(hdcTool, hbmTool);
HBITMAP hbmNew = CreateBitmap(48, 16, 1, 1, NULL);
hdcNew = CreateCompatibleDC(0);
SelectBitmap(hdcNew, hbmNew);

SetBkColor(hdcTool, (COLORREF)RGB(130, 255, 255)); // This is the background color of the tool.bmp
BitBlt(hdcNew, 0, 0, 48, 16, hdcTool, 0, 0, SRCCOPY);

// .. tidy up etc

So I have a HDC/HBITMAT to a 1 bit bitmap that is a black mask of the actual 'icons' in tool2.bmp, and the background of it is now transparent, but I can't find or understand the process of printing the color of the 'icons' in the tool.bmp to a final HBITMAP using this mask.

I've read every resource I can find on the net but I can't make sense of this final stage. This has become a brickwall in my learning project, I'd HUGELY appreciate any one who can take a moment out and reveal (and briefly explain if possible) this last step to me.
Syndication is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[WANTED] Programming Partner for Browser Toolbar Development sabian Paid Job Offers 7 Apr 6th, 2006 9:30 AM
building a browser toolbar va1damar Java 2 Mar 20th, 2006 9:29 AM
creating browser toolbar va1damar Project Ideas 2 Mar 15th, 2006 2:45 PM
Bitmap Display Probelm hemanth.balaji C++ 3 Jun 9th, 2005 7:04 AM
bitmap files Daniel_kd C 4 May 3rd, 2005 6:20 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:06 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC