Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Delphi 2009 Handbook

Project: SuperProgress.dproj

Project Structure

SuperProgress.dpr
program SuperProgress;

uses
  Forms,
  SuperProgress_MainForm in 'SuperProgress_MainForm.pas' {FormSuperProgress};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TFormSuperProgress, FormSuperProgress);
  Application.Run;
end.
SuperProgress_MainForm.pas
unit SuperProgress_MainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, ExtCtrls;

type
  TFormSuperProgress = class(TForm)
    ProgressBar1: TProgressBar;
    ProgressBar2: TProgressBar;
    ProgressBar3: TProgressBar;
    btnLoop: TButton;
    btnJump: TButton;
    btnJumpBack: TButton;
    RadioGroup1: TRadioGroup;
    procedure btnLoopClick(Sender: TObject);
    procedure btnJumpClick(Sender: TObject);
    procedure btnJumpBackClick(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormSuperProgress: TFormSuperProgress;

implementation

{$R *.dfm}

procedure TFormSuperProgress.btnJumpBackClick(Sender: TObject);
begin
  ProgressBar2.Position := (ProgressBar2.Position - 40) mod 100;
  ProgressBar3.Position := (ProgressBar3.Position - 40) mod 100;
end;

procedure TFormSuperProgress.btnJumpClick(Sender: TObject);
begin
  ProgressBar2.Position := (ProgressBar2.Position + 20) mod 100;
  ProgressBar3.Position := (ProgressBar3.Position + 20) mod 100;
end;

procedure TFormSuperProgress.btnLoopClick(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to 99 do
  begin
    ProgressBar2.Position := I*2 mod 100;
    ProgressBar3.Position := I*2 mod 100;
    Application.ProcessMessages;
    Sleep (100);
    Caption := 'SuperProgress ' + IntToStr (I);
  end;
end;

procedure TFormSuperProgress.RadioGroup1Click(Sender: TObject);
begin
  case RadioGroup1.ItemIndex of
    0: ProgressBar2.State := pbsNormal;
    1: ProgressBar2.State := pbsError;
    2: ProgressBar2.State := pbsPaused;
  end;
end;

end.
SuperProgress_MainForm.pas.dfm
object FormSuperProgress: TFormSuperProgress
  Left = 0
  Top = 0
  Caption = 'SuperProgress'
  ClientHeight = 279
  ClientWidth = 604
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object ProgressBar1: TProgressBar
    Left = 72
    Top = 56
    Width = 289
    Height = 25
    Style = pbstMarquee
    MarqueeInterval = 20
    TabOrder = 0
  end
  object ProgressBar2: TProgressBar
    Left = 72
    Top = 104
    Width = 289
    Height = 25
    Smooth = True
    SmoothReverse = True
    TabOrder = 1
  end
  object ProgressBar3: TProgressBar
    Left = 72
    Top = 152
    Width = 289
    Height = 25
    TabOrder = 2
  end
  object btnLoop: TButton
    Left = 72
    Top = 192
    Width = 75
    Height = 25
    Caption = 'btnLoop'
    TabOrder = 3
    OnClick = btnLoopClick
  end
  object btnJump: TButton
    Left = 184
    Top = 192
    Width = 75
    Height = 25
    Caption = 'btnJump'
    TabOrder = 4
    OnClick = btnJumpClick
  end
  object btnJumpBack: TButton
    Left = 286
    Top = 192
    Width = 75
    Height = 25
    Caption = 'btnJumpBack'
    TabOrder = 5
    OnClick = btnJumpBackClick
  end
  object RadioGroup1: TRadioGroup
    Left = 405
    Top = 64
    Width = 116
    Height = 97
    Caption = 'ProgressBar2 State'
    ItemIndex = 0
    Items.Strings = (
      'Normal'
      'Error'
      'Paused')
    TabOrder = 6
    OnClick = RadioGroup1Click
  end
end
HTML file generated by PasToWeb, a tool by Marco Cantù
Copyright 2008 Marco Cantù