Originally posted by: Vinayak
Hi,
I created the bitmap using vc++ 5.0 resource editor and set the color to the 256 color. And added your line of code. But the buttons are displayed as black!!!. Anything that i am missing?. If you have any sample of that, pls send it to me. Thanks in advance.
Regards,
Vinayak
Originally posted by: cdzhd
How to change background color of button in toolbar?
Thank you
Originally posted by: A.Ajit
ButtonSize.cx = 44;
m_ChildToolBar.SetBarStyle(m_ChildToolBar.GetBarStyle() |
m_ChildToolBar.EnableDocking(CBRS_ALIGN_ANY);
This is a part of the code and this gives an assertion in col->from.It does not allow to set the color.
I am using 256 color bitmaps in my toolbar and was not getting it at any cost .I was happy to come across your code and tried to implement it.Unfortunately it does not work for me.After that i also tried using the API call CreateMappedBitmap but to no avail.This API call is not allowing me to set colors.(it has a variable of type LPCOLORMAP.).I am getting assertion errors when i am setting the color.The code looks like this
/***************************************************/
SIZE ButtonSize,ImageSize;
LPCOLORMAP col;
nt CInvestigatorFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
/* if (!m_ChildToolBar.Create(this) ||
!m_ChildToolBar.LoadToolBar(IDR_INVESTIGATE))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}*/
ButtonSize.cy = 42;
ImageSize.cx = 37;
ImageSize.cy = 36;
col->from = RGB(0,0,0);
col->to = RGB(255,255,255);
m_ChildToolBar.Create(this);
::CreateMappedBitmap(
((CRangerClientApp *)AfxGetApp())->m_hInstance,
IDR_INVESTIGATE,
0,
col,
256);
m_ChildToolBar.GetToolBarCtrl().AddBitmap(13,IDR_INVESTIGATE);
m_ChildToolBar.SetButtons(buttons,
sizeof(buttons)/sizeof(UINT));
m_ChildToolBar.SetSizes(ButtonSize,ImageSize);
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_ChildToolBar);
return 0;
}
/*******************************************************/
Please give a solution.
Originally posted by: Bretislav Kotyza
When I tried to use this tricky idea in my code, where I use CToolBar in CDialog class, it simply didn't work :-(
He is one solution of this problem:
static TBBUTTON tbButtons[2] =
{{0, ID_COMMAND1, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, NULL},
{1, ID_COMMAND2, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, NULL}};
void XYZ::InitToolbar()
{
...
m_Toolbar.Create(...);
m_Toolbar.GetToolBarCtrl().AddBitmap(2, IDB_256CTOOLBARBITMAP);
m_Toolbar.GetToolBarCtrl().AddButtons(2, tbButtons);
m_Toolbar.GetToolBarCtrl().SetBitmapSize(CSize(cx, cy));
...
}
Have a fun with this code :-)
ReplyOriginally posted by: Gregory Goeppel
Thanks for the tip. My toolbar colors were drivin me nutz.
Now they look right. Thanks again.
Originally posted by: Mark Fuini
Does anyone know how to make the windows common control toolbar draw its assigned hot and cold bitmaps with a palette??
Reply