Graphical progress Bar for Delphi application
reference : http://delphi.about.com/od/delphitips2008/qt/image-progress.htm
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.
//”moves” image to the right in “step” steps
procedure UpdateImageProgress(const img : TImage) ;
step = 4;
b : TBitmap;
with img.Picture.Bitmap do
b := TBitmap.Create;
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) ;
UpdateImageProgress shifts the trailing “step” part of the bitmap to the front, moving the rest along.