statusbar学习(2)—在statusbar上显示图标和自动以颜色

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;

 

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页