To create an indicator in an application process, a lot of things to do to make it. One using the Progress Bar, where the goal is to find out the progress report of an ongoing process.
The following simple example will be discussed making ‘How To Make Simple Progress Bar with Borland Delphi 7′ by using the ProgressBar component.
Format Form
Properties:
Name: Form1
Left: 271
Top: 393
Width: 516
Height: 148
Caption: ‘Form1′
Events:
OnCreate:
procedure TForm1.FormCreate(Sender: TObject);
begin
Caption := 'Progress Bar [Simple Sample]';
lbl1.Caption := 'Click Button Starting...';
tmr1.Enabled := False;
end;
Komponen TLabel
Properties:
Name: lbl1
Left: 8
Top: 8
Width: 29
Height: 20
Caption: ‘lbl1′
Font.Name: ‘MS Sans Serif’
Font.Style: [fsBold]
ParentFont: False
Events: -
Komponen TProgressBar
Properties:
Left: 8
Top: 32
Width: 409
Height: 57
Smooth: True
Events: -
Komponen TButton
Properties:
Left: 424
Top: 32
Width: 75
Height: 57
Caption: ‘Run’
Events:
OnClick:
procedure TForm1.btn1Click(Sender: TObject);
begin
pb1.Position := 0;
tmr1.Enabled := True;
btn1.Enabled := False;
end;
Komponen: TTimer
Properties:
Interval: 100
Events:
OnTimer:
procedure TForm1.tmr1Timer(Sender: TObject);
begin
pb1.Position := pb1.Position+1;
lbl1.Caption := 'Working Position ' + IntToStr(pb1.Position+1);
if pb1.Position = 100 then
begin
tmr1.Enabled := False;
btn1.Enabled := True;
lbl1.Caption := 'End Procces';
end;
end;
Full Source Code:::
//******************************************//
// Sampel Source Code Learning Delphi //
// Simple Progress Bar //
// by : G. Giarto //
// E-Mail : support@learning-delphi.com //
// Website: http://www.learning-delphi.com //
//******************************************//
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
pb1: TProgressBar;
tmr1: TTimer;
lbl1: TLabel;
btn1: TButton;
procedure tmr1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Caption := 'Progress Bar [Simple Sample]';
lbl1.Caption := 'Click Button Starting...';
tmr1.Enabled := False;
end;
procedure TForm1.tmr1Timer(Sender: TObject);
begin
pb1.Position := pb1.Position+1;
lbl1.Caption := 'Working Position ' + IntToStr(pb1.Position+1);
if pb1.Position = 100 then
begin
tmr1.Enabled := False;
btn1.Enabled := True;
lbl1.Caption := 'End Procces';
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
pb1.Position := 0;
tmr1.Enabled := True;
btn1.Enabled := False;
end;
end.
-=Thank.you=- How To Make Simple Progress Bar with Borland Delphi 7
0 comments:
Post a Comment