效果见右图,OfficeXP里就是这样的风格,其实实现很简单,不必专门在网上找别人控件。
把StatusBar的SimplePanel设为False,点击Panels添加StatusPanel,把所有StatusPanel的Bevel设为pbNone、Style设为psOwnerDraw因为我们要自己绘制Flat风格。下面是StutasBar的OnDrawPanel事件代码:
procedureTForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
var
uAlign: UINT;
R: TRect;
begin
case Panel.Alignment of
taLeftJustify : uAlign := DT_LEFT;
taCenter : uAlign := DT_CENTER;
taRightJustify : uAlign := DT_RIGHT;
end;
uAlign := uAlign or DT_VCENTER;
with StatusBar.Canvas do begin
Pen.Color := $E1E1E1;
Brush.Color := StatusBar.Color;
Rectangle(Rect);
Brush.Style := bsClear;
R.Left := Rect.Left + 1;
R.Right := Rect.Right - 1;
R.Top := Rect.Top + 1;
R.Bottom := Rect.Bottom - 1;
DrawText(StatusBar.Canvas.Handle, PChar(Panel.Text), -1, R, uAlign);
end;
end;
右图的界面中,第一StatusPanel应该是自动调整大小的,所以还得处理StatusBar.OnResize事件,代码如下:
procedure TForm1.StatusBar1Resize(Sender: TObject);
var
i, w: integer;
begin
w := StatusBar1.Width;
for i:=1 to StatusBar1.Panels.Count-1 do
w := w - StatusBar1.Panels[i].Width;
StatusBar1.Panels[0].Width := w;
end;
效果还不错吧
//文章出自:http://blog.csdn.net/nhconch,转载请作者联系,并注明文章出处、保留作者信息,谢谢支持!
http://blog.csdn.net/nhconch/article/details/124042