mike_marquet
asked on
ToolBar buttons background color
Hi to all,
How can I change the background color of a toolbarctrl button ?
The toolbar was created in the resource editor.
I have x buttons and one of them, is a color choise button. I want foir this button that the bakground color becomes the choisen color.
Any idea to make this ?
How can I change the background color of a toolbarctrl button ?
The toolbar was created in the resource editor.
I have x buttons and one of them, is a color choise button. I want foir this button that the bakground color becomes the choisen color.
Any idea to make this ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My problem is that all bitmaps from the toolbar image list are modified.
pToolBar->GetToolBarCtrl()
is retrieving the bitmaps. The coordinates are correct but the bitmap handle is always the same if I pass 0, 1, ... image index.
Here's the code :
void SetToolBarButtonBackColor(
{
TBBUTTONINFO stBI;
stBI.cbSize = sizeof(stBI);
stBI.dwMask = TBIF_IMAGE;
pToolBar->GetToolBarCtrl()
IMAGEINFO stImageInfo;
pToolBar->GetToolBarCtrl()
TRACE("[%d] => [(%d,%d)(%d,%d)] => 0x%X , 0x%X\n", stBI.iImage, stImageInfo.rcImage.left, stImageInfo.rcImage.top, stImageInfo.rcImage.right,
CBitmap *pBitmap = CBitmap::FromHandle(stImag
BITMAP stBitmap;
pBitmap->GetBitmap(&stBitm
BYTE nBytesPixel = stBitmap.bmBitsPixel / 8;
DWORD nCount = stBitmap.bmHeight * stBitmap.bmWidth * nBytesPixel;
BYTE *pData = new BYTE[nCount];
DWORD nRet = pBitmap->GetBitmapBits(nCo
VERIFY(nRet == nCount);
memset(pData, 0, nCount);
DWORD I = 0;
while (I < nCount)
{
pData[I + 0] = GetBValue(clr);
pData[I + 1] = GetGValue(clr);
pData[I + 2] = GetRValue(clr);
I += nBytesPixel;
}
nRet = pBitmap->SetBitmapBits(nCo
VERIFY(nRet == nCount);
delete pData;
pToolBar->RedrawWindow();
}