delphi怎样把progressbar放到/嵌入到statusbar中
// 或者双击Statusbar1,添加Statusbar1.Panels[0],将其Style改为psOwnerDraw
// 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;
------------------------
或
procedure TForm1.FormCreate(Sender: TObject);
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;