Add a ProgressBar control to a dialog.  A ProgressBar is a rectangle that is gradually filled, left to right, as some work progresses.


CONTROL ADD PROGRESSBAR, hDlg, id&, txt$, x, y, xx, yy [, [style&] [, [exstyle&]]] [[,] CALL callback]


Handle of the dialog in which the ProgressBar will be created.  The dialog will become the parent of the control.


Unique identifier for the control in the range 1 to 65535, frequently specified with numeric equates for clarity of the code.  For example, the equate %PickList is more informative than a literal value such as 497. Best practice suggests identifiers should start at 100 to avoid conflict with any of the standard predefined identifiers.


Text to associate with the ProgressBar control.  A ProgressBar control does not display this text, so it is common to set this value to a null, empty string literal ("").


Integral expressions, variables, or numeric literal values specifying the location of the control inside the dialog client area.  x is the horizontal position, and y is the vertical position.  0,0 refers to the upper left corner of the dialog box client area.  Coordinates are specified in the same terms (pixels or dialog units) as the parent dialog.


Integral expressions, variable, or numeric literal values, specifying the width and height of the control. xx is the width and yy is the height, given in the same terms (pixels or dialog units) as the parent dialog.


Primary style of the ProgressBar control.  The default ProgressBar style is %WS_BORDER.  This default style is used if both the primary and extended style parameters are omitted from the statement, as in the following example:

CONTROL ADD PROGRESSBAR, hDlg, id&, "",90,90,90,20, , , CALL PBCallback()

If you include explicit style values, they replace the default values. That is, they are not added to the default styles values - your code must specify all necessary primary and extended style parameters.

The primary style value can be a combination of the standard window values, and the values specific to a ProgressBar (below), which are combined together with the OR operator to form a bitmask:


The bar is smooth rather than segmented.


The control is advanced vertically.


Extended style of the control.  The value can be a combination of the values below, combined together with the OR operator to form a bitmask:


Apply a sunken edge border to the control.


Apply a three-dimensional border style to the control (intended to be used for items that do not accept user input).


Apply a raised edge border to the control.


Optional name of a Callback Function that receives all %WM_COMMAND and %WM_NOTIFY messages for the control. See the #MESSAGES metastatement to choose which messages will be received. If a callback for the control is not designated, you must create a dialog Callback Function to process messages from your control.

If the Callback Function processes a message, it should return TRUE (non-zero) to prevent the message being passed unnecessarily to the dialog callback (if one exists).  The dialog callback should also return TRUE if the notification message is processed by that Callback Function.  Otherwise, the DDT engine processes unhandled messages.


When a Callback Function receives a %WM_COMMAND message, it should explicitly test the value of CB.CTL and CB.CTLMSG to guarantee it is responding appropriately to the notification messages.

See also