Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 06 - Project LibSpeed

Project Structure

LibSpeed.dpr
program LibSpeed;

uses
  Forms,
  SpeedForm in 'SpeedForm.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
SpeedForm.pas
unit SpeedForm;

interface

uses
  SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ScrollBox1: TScrollBox;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  time: TDateTime;
begin
  time := Now;
  for I := 0 to 500 do
  begin
    with TEdit.Create (self) do
    begin
      SetBounds (Random (ScrollBox1.ClientWidth),
        Random (ScrollBox1.ClientHeight),
        50, 16);
      Parent := ScrollBox1;
      Text := 'Edit ' + IntToStr (I);
    end;
    with TButton.Create (self) do
    begin
      SetBounds (Random (ScrollBox1.ClientWidth),
        Random (ScrollBox1.ClientHeight),
        Width, Height); // default
      Parent := ScrollBox1;
      Caption := 'Button ' + IntToStr (I);
    end;
    Application.ProcessMessages;
  end;
  time := Now - time;
  Label1.Caption := FormatDateTime ('nn:ss.zzz', time);
end;

end.
SpeedForm.dfm
object Form1: TForm1
  Left = 192
  Top = 107
  Width = 666
  Height = 446
  Caption = 'LibSpeed'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 176
    Top = 24
    Width = 32
    Height = 13
    HelpType = htKeyword
    Caption = 'Label1'
  end
  object ScrollBox1: TScrollBox
    Left = 24
    Top = 64
    Width = 625
    Height = 337
    TabOrder = 0
  end
  object Button1: TButton
    Left = 32
    Top = 16
    Width = 75
    Height = 25
    Caption = 'Test'
    TabOrder = 1
    OnClick = Button1Click
  end
end