How To Tutorials

How to Customize the PxPlus Progress Bar

Starting with PxPlus 2025, the Progress Bar interface has been updated to give it a more modern look and feel. The appearance of the progress bar can also be further customized by using the five Global Variables, which have been provided to control the different aspects of the progress bar. These variables may be set in the START_UP program or in any other program prior to initializing a progress bar.

The examples below show you how to set these five global variables. Each example provides two screenshots showing the default appearance on the left and the customized appearance on the right.

Use these links to access a particular example:

      How to Change the Progress Bar Color

      How to Change the Background Color of the Progress Bar Window

      How to Change the Font for the Text

      How to Change the Color of the Percent Indicator Text

      How to Change the Text Color

For the steps to set up the PxPlus progress bar, see How to Set Up the PxPlus Progress Bar.

Note:
Any of the colors being set by these global variables can be one of the standard PxPlus colors, an RGB color, a User-Defined color or an HTML Hex color.

If you want to have different progress bars in different applications, simply set these variables prior to initializing the progress bar.

How to Change the Progress Bar Color (%_PROGBAR_BAR_CLR)

The color of the progress bar meter can be controlled by setting the %_PROGBAR_BAR_CLR$ global variable.

Example:

     %_progbar_bar_clr$="RGB:155 0 0" (Burgundy)

    

How to Change the Background Color of the Progress Bar Window (%_PROGBAR_BACK_CLR$)

The background color of the progress bar window can be controlled by setting the %_PROGBAR_BACK_CLR$ global variable.

Example:

     %_progbar_back_clr$="Dark Gray"

    

How to Change the Font for the Text (%_PROGBAR_FONT$)

The font used for both the text (passed in as the text$ parameter) and the text on the Cancel button can be controlled by setting the %_PROGBAR_FONT$ global variable.

Example:

     %_progbar_font$="Algerian"

    

How to Change the Color of the Percent Indicator Text (%_PROGBAR_PERCENT_CLR$)

When using the CALL "*progbar;Update_percent" method, the color of the percent indicator (passed in as the percent parameter) can be controlled by setting the %_PROGBAR_PERCENT_CLR$ global variable.

    

How to Change the Text Color (%_PROGBAR_TEXT_CLR$)

The color of the text (passed in as the text$ parameter) can be controlled by setting the %_PROGBAR_TEXT_CLR$ global variable.

    

How to Set Up the PxPlus Progress Bar

The three steps below show you how to set up the three CALL routines that are required in a program to invoke the PxPlus progress bar.

These steps consist of initializing the progress bar, updating the progress bar, and then removing the progress bar window.

1. Initializing the Progress Bar

The first step is to place this CALL just before running the process or report in your program:

     CALL "*progbar;Init", title$, barsize, [ , column, row, options$, ctlno ]

Where:

title$

(Required) A string that contains the title, which will display at the top of the progress bar window.

Example:

  

barsize

(Optional) A numeric value that contains the width of the bar to be created in columns. Minimum bar size is 15.

Example:

   barsize=40

  

column, row

(Optional) Numeric values that contain the coordinates where the window will display on the screen.

Example:

   column=150, row=10 (top right corner)

  

options$

(Optional) A string that contains the attribute options to be used in the creation of the dialogue window. Typical use would be to make the dialogue windows concurrent, thereby allowing the user to access controls on the current window.

This would be the OPT=string$ settings for the dialogue window. See 'DIALOGUE' mnemonic for a list of supported options.

Example:

   options$="i,-"

   i  Window has no icon in the upper left corner.
   -  (dash/minus sign) Window has a Minimize button.

  

ctlno

(Optional) A control value used to override the default control value of 4 that will be generated by the Cancel button.

Users can cancel the process by doing one of the following:

  • Pressing the F4 key (CTL=4 is used to close most panels)
  • Pressing the ESC key
  • Clicking the Cancel button
  • Clicking the X (Close) button

When any of these methods are used, the following message displays:

    

How to Remove the Cancel Button

You may decide that you do not want the user to cancel the process because the program needs to finish properly; e.g. the program could be in a routine where files are being updated.

You can remove the Cancel button so that the program finishes correctly with no interruptions.

1.

In any progress bar program, add a flag during initialization, which will remove the Cancel button from the progress bar window:

   %_no_progbar_cancel=1;call "*progbar;init", title$, barsize, column, row, options$, ctlno

2.

During the wrapup, set another flag to %_NO_PROGBAR_CANCEL=0 to turn it Off:

   %_no_progbar_cancel=0;call "*progbar;wrap_up"

2. Updating the Progress Bar

The second step is to update the progress bar. This CALL will go into the loop where the screen is loading or the records are being accumulated for the report being generated.

Two display types for the progress bar are available to choose from: Advance Bar or Show % Complete.

          CALL "*progbar;Update" [, ERR=stmtref], text$ [ , image$ ]
          CALL "*progbar;Update_percent" [, ERR=stmtref], text$, percent, [ , image$ ]

Where:

ERR=stmtref

(Optional) An error transfer to a specific line number or statement label in which to transfer control.

Example:

  

text$

(Required) A string that contains the text to be displayed in the progress bar window.

Example:

  

Alternatively, you can create text with multiple lines by entering a carriage return/line feed ($0D0A$) after each line to improve readability.

Example:

    

image$

(Optional) A string that contains the pathname to an image that will be displayed in the top/left corner of the progress bar window.

Example:

To add a single image (e.g. an hourglass), the following syntax can be used:

     image$="C:\.myImage\hourglass48x48.png"

  

How to Animate an Image (Optional)

You can make an image appear animated by using the MOD( ) function and two images. The MOD( ) function returns the modulus/remainder from a division of the first expression by the second.

Example:

  

1.

Add a counter after the record is ready.

     recs++

2.

Using the MOD( ) function, if the remainder is not 0, the image will show the Widgets; otherwise, it will show the Update image.

     if recs|2<>0 then image$="!32X32/Buttons/Widgets" else image$="!32X32/Buttons/Update"

3.

Add a WAIT directive to pause for a second to allow the image to be updated on the screen.

     wait 1

percent

(Required) The percent parameter is used only in the Show % Complete method as a numeric value that contains the percentage of the bar to show as complete.

   CALL "*progbar;Update_percent" [, ERR=stmtref], text$, percent, [ , image$ ]

Example:

  

How to Calculate the "percent" Parameter

These steps show you how to calculate the percent parameter:

1.

Use the FIN( ) function to get the number of records in the file.

     rec=num(fin(filno_chn,"RECORDS_USED"))

2.

Set a counter within the loop where it is updating.

     recs++

3.

Take the rec counter value, divide by the total records in the file and multiply by 100 to get the percent.

     percent=(recs/rec)*100

3. Closing the Progress Bar

The third step is to remove the progress bar window. When the accumulation is complete, you can add a method for the entry point to remove the progress bar window.

     CALL "*progbar;Wrap_up"

See Also

*PROGBAR Progress Bar Display