Marco Cantù 1998, Mastering Delphi 4

Project: VFI.DPR


Project Structure


VFI.DPR

program Vfi;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.RES}

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

UNIT1.PAS

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Beep;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Beep;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  ShowMessage ('Hi');
end;

end.

UNIT2.PAS

unit Unit2;

interface

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

type
  TForm2 = class(TForm1)
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.DFM}

procedure TForm2.Button2Click(Sender: TObject);
begin
  inherited;
  ShowMessage ('Hi');
end;

procedure TForm2.Button3Click(Sender: TObject);
begin
  ShowMessage ('Hi');
end;

procedure TForm2.Button4Click(Sender: TObject);
begin
  inherited Button3Click (Sender);
  inherited;
end;

end.

UNIT1.DFM

object Form1: TForm1
  Left = 224
  Top = 142
  Width = 359
  Height = 71
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 8
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Show...'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 88
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Beep'
    TabOrder = 1
    OnClick = Button2Click
  end
  object Button3: TButton
    Left = 168
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Beep'
    TabOrder = 2
    OnClick = Button3Click
  end
  object Button4: TButton
    Left = 248
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Hi...'
    TabOrder = 3
    OnClick = Button4Click
  end
end

UNIT2.DFM

inherited Form2: TForm2
  Top = 273
  Caption = 'Form2 (Inherited from Form1)'
  PixelsPerInch = 96
  TextHeight = 13
  inherited Button1: TButton
    Visible = False
  end
  inherited Button2: TButton
    Caption = 'Beep...'
  end
  inherited Button3: TButton
    Caption = 'No Beep...'
  end
  inherited Button4: TButton
    Caption = 'Hi (Beep)...'
  end
end


Copyright Marco Cantù 1998