ProgressBar

Inheritance Hierarchy

          IComponent

          IControl

          IProgressBar

          ProgressBar

Description

The ProgressBar component is used to indicate the process of performing a task.

Working with the Component

To use the component, in  Min  and the  Max  properties define indicator scale minimum and maximum values. In the  Position  property, set the current value displayed in the indicator. Various additional properties enable users to customize component appearance.

Usage Characteristics

If you work in operating system using Aero theme, smooth progress bar is used. If values change quite rapidly (for several seconds), progress bar lag occurs. Such lag is not an error in the ProgressBar operation; it is an operating result of the system component behind the ProgressBar. If process initiated by the ProgressBar component is in progress for a short time period and timely progress bar display is required, the following bypass can be used: prior to setting in the Position property the value displayed by the indicator, a slightly increased value should be set for such property. It causes an instant drawing of the process indicator. To improve progress bar display in the end point (when the Max value is reached), slightly increase maximum permissible component range, set indicator value and reset initial maximum permissible value.

If indicator value is changed according to timer control, to enable correct display using the above algorithm the following code in Fore language can be used:

Class TESTForm: Form
    Button1: Button;
    Timer1: Timer;
    ProgressBar1: ProgressBar;
    Pos: Integer;

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Begin
        Pos := 0;
        Timer1.Enabled := True;
    End Sub Button1OnClick;

    Sub Timer1OnTimer(Sender: Object; Args: IEventArgs);
    Begin
        Pos := Pos + 1;
        If (Pos < ProgressBar1.Max) Then
            ProgressBar1.Position := Pos + 1;
            ProgressBar1.Position := Pos;
        Else
            ProgressBar1.Max := ProgressBar1.Max + 1;
            ProgressBar1.Position := ProgressBar1.Max;
            ProgressBar1.Max := ProgressBar1.Max - 1;
            Timer1.Enabled := False;
        End If;
    End Sub Timer1OnTimer;

End Class TESTForm;

It is also recommended to consider using the PPProgressBar component instead of the ProgressBar component. PPProgressBar does not depend on system components, thus display lag does not occur.

Example

Properties of the ProgressBar Component

  Property name Brief description
Align The Align property determines the behavior of the component, when the size of its parent component is changed.
AllowDrag The AllowDrag property determines whether an object can be dragged from the component.
AllowDrop The AllowDrop property determines whether the component can accept a dragged object.
Anchors The Anchors property returns settings that determine the percentage of the size change for the current component when the parent component is resized.
BorderStyle The BorderStyle property determines the style of a component border.
Brush The Brush property specifies the brush used to fill the component area.
ClientHeight The ClientHeight property is used to receive or specify the height of the component’s client space.
ClientWidth The ClientWidth property is used to receive or specify the width of the component’s client space.
Color The Color property determines the background color of a component.
ComponentCount The ComponentCount property returns the number of child components.
Components The Components property returns the child component.
Cursor The Cursor property determines the look of the cursor over the component.
Data The Data property is used to store any custom data.
Enabled The Enabled property determines whether the component is available for the user.
Focused The Focused property returns True, if the focus is set on the component.
Font The Font property determines the set of characteristics, describing the font, used to display text.
Height The Height property determines the component height.
HelpContext The HelpContext property determines a unique index for the context help section for this component.
Hint The Hint property determines the hint text for the component.
Left The Left property determines the coordinate of the left border of the component.
Max The Max property determines the maximum value for the progress bar.
Min The Min property determines the minimum value for the progress bar.
Name The Name property determines the component name.
Orientation The Orientation property determines the indicator orientation.
Parent The Parent property determines the parent component.
ParentColor The ParentColor property determines whether the component inherits the color of the parent component.
ParentFont The ParentFont property determines whether the component should use the font of the parent component.
ParentShowHint The ParentShowHint property determines when a tooltip is displayed.
PopupMenu The PopupMenu property determines the context menu to be displayed on right-click.
Position The Position property determines the current position of the indicator.
Scrolls The Scrolls property returns parameters of component's scrollbars.
ShowHint The ShowHint property enables and disables showing a hint for the component.
Smooth The Smooth property determines the indicator appearance.
StepSize The StepSize property determines the value to move the indicator on calling of the method StepIt .
TabOrder The TabOrder property determines the component position in the tab order.
TabStop The TabStop property determines whether the focus is set to a component when the TAB button is pressed.
Tag The Tag property is not used by the compiler. The user can change the value of the Tag property and use it as required.
Text The Text property determines the row identifying a component for user.
Top The Top property determines the coordinate of the top border of the component.
Visible The Visible property determines the visibility of the component during execution.
Width The Width property determines the component width.

Methods of the ProgressBar Component

  Method name Brief description
BringToFront The BringToFront method brings a component to front.
ClientToScreen The ClientToScreen method converts point coordinates relative to component coordinates into display coordinates.
DoDragDrop The DoDragDrop method allows to start drag-and-drop operation.
GetImage The GetImage method returns the image of the component with all the child components.
ScreenToClient The ScreenToClient method converts screen coordinates of a point to coordinates specified relative to the component coordinate system.
SendToBack The SendToBack method sends a component to back.
SetFocus The SetFocus method sets focus to this component.
StepBy The StepBy method changes the indicator position by the value, set in the input parameter.
StepIt The StepIt method changes the indicator position by the value, set in the StepSize property.

Events of the ProgressBar Component

  Event name Brief description
OnBeginDrag The OnBeginDrag event occurs for a component, when a user starts to drag an object from the component.
OnClick The OnClick event occurs if a user clicks a component area using the main mouse button.
OnDblClick The OnDblClick event occurs if a user double-clicks a component area using the mouse button.
OnDragDrop The OnDragDrop event occurs for a component if a user drops a dragged object over it.
OnDragEnter The OnDragEnter event occurs when a dragged object crosses the borders of this component.
OnDragLeave The OnDragLeave event occurs when a dragged object leaves the borders of this component.
OnDragOver The OnDragOver event occurs for this component when a user drags a dragged object over it.
OnEnter The OnEnter event occurs when a component receives focus.
OnExit The OnExit event occurs when a component loses focus.
OnHScroll The OnHScroll event occurs when the horizontal scrollbar slider changes its position.
OnKeyDown The OnKeyDown event occurs if a component is focused and a keyboard key is pressed.
OnKeyPress The OnKeyPress event occurs if a component is focused when a user presses a character key.
OnKeyPreview The OnKeyPreview event occurs prior to each event requiring clicking.
OnKeyUp The OnKeyUp event occurs if a component is focused and a user releases any button previously pressed.
OnMouseDown The OnMouseDown event occurs when the pointer is in component area and a mouse button is pressed.
OnMouseEnter The OnMouseEnter event occurs when mouse cursor enters the component area.
OnMouseHover The OnMouseHover event occurs when mouse cursor is held in the component area.
OnMouseLeave The OnMouseLeave event occurs when mouse cursor leaves the component area.
OnMouseMove The OnMouseMove event occurs on moving the cursor over component.
OnMouseUp The OnMouseUp event occurs on releasing mouse button when the cursor is in component area.
OnMouseWheel The OnMouseWheel event occurs if the component has focus when the mouse wheel is rotated.
OnVScroll The OnVScroll event occurs when the vertical scrollbar slider changes its position.

See also:

Additional Components