procedure TForm2.FormCreate(Sender: TObject);
begin
StatusBar1.Panels[0].Style := psOwnerDraw;
StatusBar1.Panels[1].Style := psOwnerDraw;
end;
procedure TForm2.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
with StatusBar.Canvas do
begin
case Panel.Index of
0:
begin
Brush.Color := clRed;
Font.Color := clNavy;
Font.Style := [fsBold];
end;
1:
begin
Brush.Color := clYellow;
Font.Color := clTeal;
Font.Style := [fsItalic];
end;
end;
FillRect(Rect);
TextRect(Rect, 2 + ImageList1.Width + Rect.Left, 2 + Rect.Top, Panel.Text);
end;
// draw graphics
ImageList1.Draw(StatusBar1.Canvas, Rect.Left, Rect.Top, Panel.Index);
end;
本文介绍了一个使用 Delphi 实现自定义状态栏样式的示例代码。通过设置不同面板的背景颜色、字体颜色和样式,实现了两个面板分别显示为红色背景、蓝色粗体文字和黄色背景、绿色斜体文字的效果,并通过 ImageList 在状态栏中添加了图标。
1120

被折叠的 条评论
为什么被折叠?



