RT
statusbar.align:=albottom;
statusbar.Panels.Items[0].Text='Test ';
statusbar.panels.items[0].width=100;
statusbar.Panels.Items[1].Text='Test ';//将progressbar 放到这个地方
statusbar.panels.items[1].width=200;
statusbar.Panels.Items[2].Text='Test ';
statusbar.panels.items[2].width=100;
statusbar.align:=albottom;
statusbar.Panels.Items[0].Text='Test ';
statusbar.panels.items[0].width=100;
statusbar.Panels.Items[1].Text='Test ';//将progressbar 放到这个地方
statusbar.panels.items[1].width=200;
statusbar.Panels.Items[2].Text='Test ';
statusbar.panels.items[2].width=100;
先在窗体上放一个Panel,
然后双击Statusbar1,添加Statusbar1.Panels[0],将其Style改为psOwnerDraw
然后在FormCreate中写
Panel1.Parent := StatusBar1;
Panel1.Left := StatusBar1.left;
Panel1.Top := 0;
你在Panel1上什么都可以放,包括Progressbar,button等等。
// StatusBar的OnDrawPanel事件procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
ProgressBar1.Parent := StatusBar1;
ProgressBar1.Left := Rect.Left;
ProgressBar1.Top := Rect.Top;
Panel.Width := ProgressBar1.Width;
ProgressBar1.Height := Rect.Bottom - Rect.Top;
end;
var
ProgressBarStyle: integer;
begin
//enable status bar 2nd Panel custom drawing
StatusBar1.Panels[1].Style := psOwnerDraw; //place the progress bar into the status bar
ProgressBar1.Parent := StatusBar1; //remove progress bar border
ProgressBarStyle := GetWindowLong(ProgressBar1.Handle,
GWL_EXSTYLE);
ProgressBarStyle := ProgressBarStyle
- WS_EX_STATICEDGE;
SetWindowLong(ProgressBar1.Handle,
GWL_EXSTYLE,
ProgressBarStyle);
end;
procedure TForm1.StatusBar1DrawPanel(
StatusBar: TStatusBar;
Panel: TStatusPanel;
const Rect: TRect);
begin
if Panel = StatusBar.Panels[1] then
with ProgressBar1 do begin
Top := Rect.Top;
Left := Rect.Left;
Width := Rect.Right - Rect.Left - 15;
Height := Rect.Bottom - Rect.Top;
end;
end;
Delphi编程技巧--> VCL.可视组件--〉状态栏和进度条--〉 状态栏允许放入其他控件