Salvador
Salvador

Reputation: 16472

set the background color of a themed StatusBar component

How can I set the background color of a themed TStatusBar component? When I set the color property, it only works if the Enabled runtime themes is disabled.

thanks in advance.

Upvotes: 1

Views: 4060

Answers (2)

user741875
user741875

Reputation:

Not sure if this is exactly what you require, but you could simply disable the Theme Painting for a specific control, in this case your Statusbar, like so:

Uses
  uxTheme;

SetWindowTheme(StatusBar1.Handle, '', '');

Upvotes: 2

Andreas
Andreas

Reputation: 1364

You can write your own OwnerDraw-Event and draw the StatusBar (to be precise: every Panel on it!) with your own colors:

procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
  with StatusBar.Canvas do begin
    Brush.Color := clRed;
    FillRect(Rect);
    TextOut(Rect.Left, Rect.Top, 'Panel '+IntToStr(Panel.Index));
  end;
end;

But with themes on it is not possible to change the color in the Object-Inspector.

Upvotes: 1

Related Questions