cjm20
asked on
In Visual C++ App, disabled toolbar buttons show as solid grey boxes
I have a VC++ app created using VS2012. In said app, I have a few toolbars. When the toolbar images are enabled, the images on each toolbar button display nicely. However, when a toolbar button is disabled (intentionally), the image(s) on the toolbar buttons display as a solid grey boxes, instead of as a greyed out (disabled) version of the original image.
Here's some more detail:
I am loading the images at run-time by using the following:
CToolBarCtrl& bar = m_wndMyToolBar.GetToolBarC trl();
CImageList *pList = bar.GetImageList();
HICON hIconSomeImage = LoadIcon(AfxGetInstanceHan dle(), MAKEINTRESOURCE(IDI_SOME_E NABLED_ICO N));
pList->Replace(0, hIconSomeImage);
bar.SetImageList(pList);
m_wndMyToolBar.Invalidate( );
This code works well to get the image to display when the toolbar button is enabled.
To solve the issue of the image being a solid grey box when the toolbar button is disabled, I tried creating an image list for disabled toolbar images, as follows:
CImageList m_imgListDisabled;
imgListDisabled.Create(16, 15, ILC_COLOR32, 8, 8);
HICON hIconTest = LoadIcon(AfxGetInstanceHan dle(), MAKEINTRESOURCE(IDR_SOME_D ISABLED_IC ON));
m_imgListDisabled.Add(hIco nTest);
bar.SetDisabledImageList(& m_imgListD isabled);
m_wndMyToolBar.Invalidate( );
The above code compiles, and runs without throwing any errors, yet the net result is a solid grey box instead of the disabled image.
I should add that the images I am using for the toolbar buttons are icon files (.ico files), and these icons have a high color depth.
Any help would be greatly appreciated.
Here's some more detail:
I am loading the images at run-time by using the following:
CToolBarCtrl& bar = m_wndMyToolBar.GetToolBarC
CImageList *pList = bar.GetImageList();
HICON hIconSomeImage = LoadIcon(AfxGetInstanceHan
pList->Replace(0, hIconSomeImage);
bar.SetImageList(pList);
m_wndMyToolBar.Invalidate(
This code works well to get the image to display when the toolbar button is enabled.
To solve the issue of the image being a solid grey box when the toolbar button is disabled, I tried creating an image list for disabled toolbar images, as follows:
CImageList m_imgListDisabled;
imgListDisabled.Create(16,
HICON hIconTest = LoadIcon(AfxGetInstanceHan
m_imgListDisabled.Add(hIco
bar.SetDisabledImageList(&
m_wndMyToolBar.Invalidate(
The above code compiles, and runs without throwing any errors, yet the net result is a solid grey box instead of the disabled image.
I should add that the images I am using for the toolbar buttons are icon files (.ico files), and these icons have a high color depth.
Any help would be greatly appreciated.
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 kind of solution: nice and simple :)
ASKER