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 QLibSpeed

Project Structure

QLibSpeed.dpr
program QLibSpeed;

uses
  QForms,
  QSpeedForm in 'QSpeedForm.pas' {Form1};

{$R *.res}

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

interface

uses
  SysUtils, Classes, Types, QGraphics, QControls, QForms,
  QDialogs, QStdCtrls;

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 *.xfm}

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.
QSpeedForm.xfm
object Form1: TForm1
  Left = 192
  Top = 107
  Width = 662
  Height = 417
  VertScrollBar.Range = 401
  HorzScrollBar.Range = 649
  ActiveControl = Button1
  Caption = 'LibSpeed'
  Color = clBackground
  PixelsPerInch = 96
  TextHeight = 13
  TextWidth = 6
  object Label1: TLabel
    Left = 176
    Top = 24
    Width = 32
    Height = 13
    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