Home > Progress bar > Graphical progress Bar for Delphi application

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) ;
      Assign(b) ;
      FreeAndNil(b) ;

UpdateImageProgress shifts the trailing “step” part of the bitmap to the front, moving the rest along.

Categories: Progress bar Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: