Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Mastering Delphi 5

Project CREATORD

Project Structure


CREATORD.DPR

program CreatOrd;

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

{$R *.RES}

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

CREATEF.PAS

unit CreateF;

interface

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

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    ListBox2: TListBox;
  public
    constructor Create (AOwner: TComponent); override;
    procedure AfterConstruction; override;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox1.Items.Add ('OnCreate');

  ListBox2 := TListBox.Create (Self);
  ListBox2.Parent := Self;
  ListBox2.Align := alClient;
  ListBox2.Items.Add ('A first item');
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  ListBox1.Items.Add ('OnShow');
end;

constructor TForm1.Create(AOwner: TComponent);
begin
  inherited Create (AOwner);

  ListBox1.Items.Add ('After inherited create');
  if Assigned (ListBox2) then
    ListBox2.Items.Add ('A second item');
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  ListBox1.Items.Add ('OnActivate');
end;

procedure TForm1.AfterConstruction;
begin
  inherited AfterConstruction;
  ListBox1.Items.Add ('After inherited AfterConstruction');
end;

end.

CREATEF.DFM

object Form1: TForm1
  Left = 226
  Top = 206
  Width = 554
  Height = 416
  Caption = 'Create Order'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnActivate = FormActivate
  OnCreate = FormCreate
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object ListBox1: TListBox
    Left = 0
    Top = 0
    Width = 546
    Height = 193
    Align = alTop
    ItemHeight = 13
    TabOrder = 0
  end
end