When your application performs a time-consuming operation, you can use a progress bar, the TProgressBar Delphi control, to show how much of the task is completed.
When you do not know how many steps are needed for a progress bar - you might want to display a continuous bar - or a moving graphical object. The UpdateImageProgress takes a reference to a TImage control displaying a picture. By calling the procedure from inside, for example, a timer event (TTimer control), a graphical progress effect is achieved.
The UpdateImageProgress shifts the image to the right - using the boundaries of the image - thus creating a continuous progress bar.
UpdateImageProgress shifts the trailing "step" part of the bitmap to the front, moving the rest along.
//"moves" image to the right in "step" steps procedure UpdateImageProgress(const img : TImage) ; const step = 4; var b : TBitmap; begin with img.Picture.Bitmap do begin b := TBitmap.Create; try b.Width := Width; b.Height := Height; BitBlt(b.Canvas.Handle, step, 0, Width-step, Height, Canvas.Handle, 0, 0, SRCCOPY) ; BitBlt(b.Canvas.Handle, 0, 0, step, Height, Canvas.Handle, Width-step, 0, SRCCOPY) ; Assign(b) ; finally FreeAndNil(b) ; end; end; end;