Please see the attached screenshot which illustrates a TToolBar from one of my programs:
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 passing Enabled=False
– nothing else looks that bad! Are you 100% sure this really is a TToolbar
?
The fix will surely be to avoid TImageList.Draw
and call ImageList_DrawIndirect
with the ILS_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
.
procedure DrawDisabledImage(DC: HDC; ImageList: TCustomImageList; Index, X, Y: Integer);
var
Options: TImageListDrawParams;
begin
ZeroMemory(@Options, SizeOf(Options));
Options.cbSize := SizeOf(Options);
Options.himl := ImageList.Handle;
Options.i := Index;
Options.hdcDst := DC;
Options.x := X;
Options.y := Y;
Options.fState := ILS_SATURATE;
ImageList_DrawIndirect(@Options);
end;
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 the TImageList.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 call TImageList.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.