Icon Showing Progress Dialogs

Progress dialogs are critical in a visual client application for displaying progress while the application is executing code or the application is waiting on an event handler to complete, such as an event handler for the TServerRequest OnComplete event. There are two procedures that provide the progress dialog functionality:
  • ShowProgress - This procedure simply displays an animated icon and a message to the user using a modal dialog containing the message.


  • HideProgress - This procedure hides any active progress dialog.
Warning The ShowProgress and HideProgress procedures are reference-counted, so you should always ensure that you call the HideProgress procedure as many times as you call the ShowProgress procedure.

The following example shows how you would show such a progress dialog:

procedure TMainForm.LoadCustomers;
begin
   ShowProgress('Loading customers...');
   Customer.AfterLoad:=CustomerAfterLoad;
   Customer.OnLoadError:=CustomerLoadError;
   Database.LoadRows(Customer);
end;

procedure TMainForm.CustomerAfterLoad(Sender: TObject);
begin
   HideProgress;
end;

procedure TMainForm.CustomerLoadError(Sender: TObject; const ErrorMsg: String);
begin
   HideProgress;
   MessageDlg(ErrorMsg,'Error loading customers',mtError,[mbOk]);
end;
Image