private progressbar:tprogressbar; //进度条组件 progressbarrect:trect; procedure TForm1.Button2Click(Sender: TObject); var i,stepcount:integer; begin progressbar:=tprogressbar.Create(form1); stepcount:=2000; with progressbar do begin top:=progressbarrect.Top ; left:=progressbarrect.Left ; width:=progressbarrect.Right -progressbarrect.Left ; height:=progressbarrect.Bottom-progressbarrect.Top ; try parent:=statusbar1; min:=0; max:=stepcount; step:=2; for i:=1 to max do begin position:=position+i; end; showmessage('操作完成'); finally end; end; end;
----------------------------------------------
-
古董贴,再翻新一下: 楼上所述均有道理,但都不符合“编程享受”之原则!建议用附件轻松搞定,尽情享受编程之乐趣吧! 声明:控件已在D2009及之前版本测试OK,在D2010上未作测试,留请“好事者”进行,并回馈信息为盼! Paaendix: IMPROVEMENTS (in comparison with TStatusBar) TStatusBarPro has the following new properties in Delphi 4 or higher:
Images: TCustomImageList Holds a list of bitmaps that can be displayed on the panels of the control. AutoHintPanelIndex: Integer When AutoHint property set to true, determines on which panel hint text appears. TStatusBarPro has the following new properties in Delphi 3:
Images: TImageList Holds a list of bitmaps that can be displayed on the panels of the control. Color: TColor Specifies the background color of the control. UseSystemFont: Boolean Specifies whether the status bar uses the system font. Type of the following event has changed:
OnDrawPanel: TDrawPanelProEvent TDrawPanelProEvent = procedure(StatusBar: TStatusBarPro; Panel: TStatusPanelPro; const Rect: TRect) of object Occurs when an owner draw panel needs to be redrawn. Type of the following property has changed:
Panels: TStatusPanelsPro Contains lists of the status bar's panels (TStatusPanelPro). Each panel (TStatusPanelPro) has the following new properties:
AutoSize: Boolean Determines whether the width of the panel should be automatically adjusted according to the StatusBarPro's size. Setting this property to True, with set the AutoWidth property to False. AutoWidth: Boolean Determines whether the width of the panel should be automatically adjusted according to the content of the panel. Setting this property to True, with set the AutoSize property to False. Color: TColor Specifies the background color of the panel. ParentColor: Boolean Determines whether the panel uses the color of the TStatusBarPro that owns it. ImageIndex: TImageIndex Determines index of the image (from the TStatusBarPro.Images) that appears on the panel. Indent: Integer Specifies how far the panel's contents (image and text) are indented. Font: TFont Specifies the font to use when writing text on the panel. MaxWidth: Integer Specifies the maximum size of the panel in pixels. When the AutoSize property is True, changing this propery has no effect. MinWidth: Integer Specifies the minimum size of the panel in pixels. When the AutoSize property is True, changing this propery has no effect. ParentFont: Boolean Determines where the panel looks for its font information. Hint: String Contains the text string that can appear when the user moves the mouse over the panel. If this property set to blank, hint property of TStatusBarPro will be used. PopupMenu: TPopupMenu Identifies the pop-up menu associated with the panel. If this property set to nil, PopupMenu property of TStatusBarPro will be used. Control: TControl Determines the control that is assigned to the panel. When a control assigns to this property, the parent of the control changes to the status bar and the control covers the panel's bounding rectangle. Each panel (TStatusPanelPro) has the following new events:
OnClick: TNotifyEvent Occurs when the use click the panel. If this event is unassigned, the OnClick event of TStatusBarPro will be fired. OnDblClick: TNotifyEvent Occurs when the user double-clicks the primary mouse button when the mouse pointer is over the panel. If this event is unassigned, the OnDblClick event of TStatusBarPro will be fired. OnContectPopup: TContextPopupEvent Occurs when the user right-clicks the panel.