Updating a progress bar during long calculations

Problem: FMX progress bar won’t update

Solution tested on C++ Builder 10.2

Suppose you’re doing a long calculation that doesn’t involve FireMonkey components. You’d like to update the user with a progress bar. You periodically take a break in the computations to update the progress bar. However, when you run your program, the progress bar doesn’t move.

The solution is to call Application->ProcessMessages() after updating the progress bar. Application is a global variable present in all FireMonkey programs. The code below is an example of the problem and its solution. (By the way, this problem also occurs with the animation indicator and other GUI elements such as a label, and you can solve it with the same technique.)
Continue reading “Updating a progress bar during long calculations”