Please see the attached screenshot which illustrates a TToolBar from one of my programs:
Notice the last two images of the Toolbar, they are disabled. The way they have been drawn to appear disabled is not very appealing, in fact in the Delphi IDE some of the images look the same.
The issue I have with it is I want my application to look a lot cleaner. The way the disabled items are drawn doesn't look very good. The TToolBar allows to set a disabled TImageList, I tried making my images black & white but they didn't look right, and would rather not have to always make the images black and white (time and effort). This problem also shows in my menus and popup menus, which don't allow for disabled images anyway.
Is there a way to paint the disabled items to look better on the eye?
If possible I would rather not look to use 3rd Party Controls. I know the Jedi Components allow disabled images for the menu etc, but would prefer a way to not resort too 3rd Party Components, when possible I would much prefer to use the standard issue VCL, especially as sometimes I use the TActionMainMenuBar to draw Office Style menus, which match the TToolBar when DrawingStyle is set to gradient.
EDIT
I have accepted RRUZ's answer, is it possible though to accept David's answer as well, both are very good answers and would like the answer to be shared between them if possible.
Thanks.
Sometime Ago i wrote a patch to fix this behavior. the key is patch the code of the
TCustomImageList.DoDraw
function, the technique used is similar to the used by thedelphi-nice-toolbar
app, but instead of patch a bpl IDE in this case we patch the function in memory.Just include this unit in your project
and the result will be
Use TActionToolbar , TActionmanager , Timagelist
Set action managers image list to a Timagelist. and set Disabledimages to another imagelist
I submitted a QC report for a related issue over a year ago, but that was for menus. I've never seen this for
TToolbar
since it is a wrapper to the common control and the drawing is handled by Windows.However, the images you are seeing are clearly as result of the VCL calling
TImageList.Draw
and passingEnabled=False
– nothing else looks that bad! Are you 100% sure this really is aTToolbar
?The fix will surely be to avoid
TImageList.Draw
and callImageList_DrawIndirect
with theILS_SATURATE
.You may need to modify some VCL source. First find the location where the toolbar is being custom drawn and call this routine instead of the calls to
TImageList.Draw
.An even better fix would be to work out why the toolbar is being custom drawn and find a way to let the system do it.
EDIT 1
I've looked at the Delphi source code and I'd guess that you are custom drawing the toolbar, perhaps because it has a gradient. I never even knew that TToolbar could handle custom drawing but I'm just a plain vanilla kind of guy!
Anyway, I can see code in
TToolBar.GradientDrawButton
calling theTImageList.Draw
so I think the explanation above is on the right track.I'm fairly sure that calling my
DrawDisabledImage
function above will give you better results. If could find a way to make that happen when you callTImageList.Draw
then that would, I suppose, be the very best fix since it would apply wholesale.EDIT 2
Combine the function above with @RRUZ's answer and you have an excellent solution.
Take a look at this Delphi IDE fix. Maybe you can mimic it's implementation.
Solution from @RRUZ dosn't work if you use LargeImages in ActionToolBar. I made changes to the @RRUZ code to work with LargeImages in ActionToolBar.