您现在的位置:首页 >> VCL >> VCL >> 内容

Delphi中自画TStatusBar面板中的文字颜色背景以及图片

时间:2011/9/3 16:23:12 点击:

  核心提示:600) this.width = 600;'>首先定义:procedure TStatusForm.FormCreate(Sender: TObject) ;beginStatusBar1.Pane...

600) this.width = 600;">

 

首先定义:

procedure TStatusForm.FormCreate(Sender: TObject) ;
begin
  StatusBar1.Panels[0].Style := psOwnerDraw;
  StatusBar1.Panels[1].Style := psOwnerDraw;
end;

自画事件:

procedure TStatusForm.StatusBar1DrawPanel(
  StatusBar: TStatusBar;
  Panel: TStatusPanel;
  const Rect: TRect) ;
begin
  with StatusBar.Canvas do
  begin
    case Panel.Index of
      0: //fist panel
      begin
        Brush.Color := clRed;
        Font.Color := clNavy;
        Font.Style := [fsBold];
      end;
      1: //second panel
      begin
        Brush.Color := clYellow;
        Font.Color := clTeal;
        Font.Style := [fsItalic];
      end;
    end;
    //Panel background color
    FillRect(Rect) ;

    //Panel Text
    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;

作者:站长 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号