maxfax
maxfax

Reputation: 4315

Delphi: gradient like in tool bar

I need a tool bar with a gradient, but I want normal buttons without a hot track. I do as a TToolBar class do:

My code:

procedure TForm7.ToolBar1CustomDraw(Sender: TToolBar; const ARect: TRect;
      var DefaultDraw: Boolean);
begin
 GradientFillCanvas(sender.Canvas, clWindow, $00D6D6D6, ARect, gdVertical); //a GraphUtil unit
end;

Tool bar's function from a ComCtrls unit:

function TToolBar.GradientDrawToolBar(const ARect: TRect): Boolean;
begin
  Result := True;
  if gdoGradient in GradientDrawingOptions then
    GradientFillCanvas(Canvas, FGradientStartColor, FGradientEndColor,
      ARect, GradientDirection);
end;

Why do I have different results?

enter image description here

Added:

GetShadowColor(clBtnFace, -25) = $00D6D6D6 for me

Upvotes: 2

Views: 1339

Answers (1)

Nathanial Woolls
Nathanial Woolls

Reputation: 5291

If you check the source for ComCtrls, the value for FGradientEndColor is GetShadowColor(clBtnFace, -25), which is based on a system color and may change depending on Windows appearance settings. Try using the same value in your custom draw code instead of $00D6D6D6.

Upvotes: 2

Related Questions