|
-
April 11th, 2010, 11:50 PM
#1
Transparent ICON Background
I have developed an Internet Explorer Searchbar using ATL COM with the help of this tutorial
http://www.codeproject.com/KB/shell/...rtutorial.aspx
There is one small problem. The background of the icons is black instead of transparent. This is the code for attaching ICONS with the toolbar
Code:
LRESULT CMFToolbar::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// buttons with images and text
SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_MIXEDBUTTONS);
// Sets the size of the TBBUTTON structure.
SendMessage(m_hWnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
// Set the maximum number of text rows and bitmap size.
SendMessage(m_hWnd, TB_SETMAXTEXTROWS, 1, 0L);
SendMessage(m_hWnd, TB_SETROWS, MAKEWPARAM(1, 0), (LPARAM)NULL);
SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DRAWDDARROWS);
// add our button's caption to the toolbar window
TCHAR* pCaption = _T("Members");
int iIndex = ::SendMessage(m_hWnd, TB_ADDSTRING, 0,(LPARAM)pCaption);
TCHAR* pCaption1 = _T("Forums");
int iIndex1 = ::SendMessage(m_hWnd, TB_ADDSTRING, 0,(LPARAM)pCaption1);
// load our button's icon and create the image list to house it.
HICON hMotley = (HICON)LoadImage(_Module.m_hInst, MAKEINTRESOURCE(IDI_ICON1_SEARCH),
IMAGE_ICON, 16, 16, LR_SHARED | LR_DEFAULTCOLOR);
//LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_ICON1_SEARCH));
m_hImageList = ImageList_Create(16,16, ILC_COLOR16 | ILC_MASK, 1, 0);
int iImageIndex = ImageList_AddIcon(m_hImageList, hMotley);
HICON hForums = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_ICON_FORUMS));
int iImageIndex1 = ImageList_AddIcon(m_hImageList, hForums);
DestroyIcon(hMotley);
DestroyIcon(hForums);
// Set the toolbar's image
::SendMessage(m_hWnd, TB_SETIMAGELIST, 0, (LPARAM)m_hImageList);
// add the button for the toolbar to the window
TBBUTTON Button;
ZeroMemory((void*)&Button, sizeof(TBBUTTON));
Button.idCommand = IDM_GETQUOTE;
Button.fsState = TBSTATE_ENABLED;
Button.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE | TBSTYLE_DROPDOWN;
Button.dwData = 0;
Button.iString = NULL;
Button.iBitmap = iImageIndex;
::SendMessage(m_hWnd, TB_INSERTBUTTON, 0, (LPARAM)&Button);
TBBUTTON Button1;
ZeroMemory((void*)&Button1, sizeof(TBBUTTON));
Button1.idCommand = IDM_FORUM;
Button1.fsState = TBSTATE_ENABLED;
Button1.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT | TBSTYLE_TRANSPARENT/*| BTNS_DROPDOWN*/;
Button1.dwData = 0;
Button1.iString = iIndex1;
Button1.iBitmap = iImageIndex1;
::SendMessage(m_hWnd, TB_INSERTBUTTON, 1, (LPARAM)&Button1);
m_hMenu = CreatePopupMenu();
AppendMenu (m_hMenu, MF_ENABLED | MF_STRING, 0, _T("Forums"));
AppendMenu (m_hMenu, MF_ENABLED | MF_STRING, 1, _T("Sessions"));
AppendMenu (m_hMenu, MF_ENABLED | MF_STRING, 2, _T("Application"));
AppendMenu (m_hMenu, MF_ENABLED | MF_STRING, 3, _T("Cache"));
//CheckMenuItem (m_hMenu, 0, MF_CHECKED | MF_BYCOMMAND);
// create our EditQuote window and set the font.
RECT rect = {0,0,0,0};
m_EditWnd.Create(m_hWnd, rect, NULL, WS_CHILD|WS_VISIBLE, WS_EX_CLIENTEDGE);
m_EditWnd.SetFont(static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)));
return 0;
}
So how can I make those ICONS with transparent background??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|