[Solved] Show progress on Ui [closed]


The best approach is define an Event on your datamodule and then implement a handler for the event in your form and assign it to datamodule event.
Then, in your process, you invoke the event and thereby call the event handler.

Something like this:

type
  TMyProgressEvent = procedure (Position, TotalSteps: Integer; Msg: string) of object

TMyDM = class
private
  FOnProgress: TMyProgressEvent;
....
....
public
  procedure UpdateCustomerOrders;
  property OnProgress: TMyProgressEvent read FOnProgress write FOnProgress;
end

TMyForm = class
....
....
  // you can change the position or progress bar here
  // or if you want to log 
  procedure MyFormProress(Position, TotalSteps: Integer; Msg: string);
end

Your TMyDM.UpdateCustomerOrders may look like this:

 procedure TMyDM.UpdateCustomerOrders()
 begin
   for I = 1 to 10 do 
   begin
     ... 
     ... you are processing something 
     ...
     //call event like this
     FOnProgress(I, 12, 'looping');
   end;
   .... another process here
   FOnProgress(11, 12, 'another process');

   .... one more process here
   FOnProgress(12, 12, 'process finished');
 end;

9

solved Show progress on Ui [closed]