Monday, December 18, 2006

How do you get mfc to let you display a 256 color toolbar.

Problem:
How do you get mfc to let you display a 256 color toolbar.

Solution:

HRESULT hr = S_OK;

if(SUCCEEDED(hr))

{

hr = m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD WS_VISIBLE CBRS_TOP CBRS_GRIPPER CBRS_TOOLTIPS CBRS_FLYBY CBRS_SIZE_DYNAMIC) m_wndToolBar.LoadToolBar(IDR_MAINFRAME) ? hr : E_FAIL;

}

if(SUCCEEDED(hr))

{

CImageList *pImgList = m_wndToolBar.GetToolBarCtrl().GetImageList();
pImgList->DeleteImageList();
pImgList->Create(16, 16, ILC_COLOR8 ILC_MASK, 0, 5);
m_wndToolBar.GetToolBarCtrl().SetImageList(pImgList);
m_wndToolBar.GetToolBarCtrl().AddBitmap(5, IDR_MAINFRAME)

}

I couldn't get either of these suggestions to work.
http://www.codeguru.com/cpp/controls/toolbar/miscellaneous/article.php/c2527/
http://tanvon.wordpress.com/2006/09/19/how-to-make-256-color-toolbar/


Keywords:16 256 colors mfc toolbar

No comments: