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 5

Project FIRE

Project Structure


FIRE.DPR

program Fire;

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

{$R *.RES}

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

FIREFORM.PAS

unit FireForm;

interface

uses Windows, Classes, Graphics, Forms,
  Controls, Buttons, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    BitBtnFire: TBitBtn;
    procedure BitBtnFireMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BitBtnFireMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BitBtnFireClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  MmSystem;

procedure TForm1.BitBtnFireMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  // load firing cannon bitmap
  if Button = mbLeft then
    BitBtnFire.Glyph.LoadFromFile ('fire2.bmp');
end;

procedure TForm1.BitBtnFireMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  // load default cannon bitmap
  if Button = mbLeft then
    BitBtnFire.Glyph.LoadFromFile ('fire.bmp');
end;

procedure TForm1.BitBtnFireClick(Sender: TObject);
begin
  PlaySound ('Boom.wav', 0, snd_Async);
  MessageDlg ('Boom!', mtWarning, [mbOk], 0);
end;

end.

FIREFORM.DFM

object Form1: TForm1
  Left = 224
  Top = 159
  Width = 261
  Height = 211
  ActiveControl = BitBtnFire
  Caption = 'Fire Form'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBlack
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  PixelsPerInch = 96
  TextHeight = 13
  object BitBtnFire: TBitBtn
    Left = 64
    Top = 56
    Width = 121
    Height = 57
    Caption = 'Fire'
    TabOrder = 0
    OnClick = BitBtnFireClick
    OnMouseDown = BitBtnFireMouseDown
    OnMouseUp = BitBtnFireMouseUp
    Glyph.Data = {
      76020000424D7602000000000000760000002800000020000000200000000100
      0400000000000002000000000000000000001000000000000000000000000000
      80000080000000808000800000008000800080800000C0C0C000808080000000
      FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00000000000000
      000000000000000000000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA00AAAAAAAAAAA
      AAAAAAAAAAAAAAAAAAA00EEEEEE0000000EEEAAAAAAAAAAAAAA00EEEEEE00000
      00EEEEEAAAAAAAAAAAA00EEEEEE00000080EEEEEEEEAAAAAAAA00EEEEE008000
      8880EEEEEEEEEEAAAAA00EEEEE08888888880EEEEEEEEEEEAAA00EEEEE087888
      888880EEEEEEEEEEEEA00EEEEE08F7888888880EEEEEEEEEEEE00EEEEEE08F78
      88888880EEEEEEEEEEE00EEEEEEE08F78888880EEEEEEEEEEEE00EEEEEEEE08F
      788880EEEEEEEEEEEEE00EEEEEEEEE08F7880EEEEEEEEEEEEEE00EEEEEEEEEE0
      8880EEEEEEEEEEEEEEE00EEEEEEEEEEE080EEEEEEEEEEEEEEEE00EEEEEEEEEEE
      E0EEEEEEEEEEEEEEEEE00EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE00EEEEEEEEEEE
      EEEEEEEEEEEEEEEEEEE00EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE00EEEEEEEEEEE
      EEEEEEEEEEEEEEEEEEE00EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE00EEEEEEEEEEE
      EEEEEEEEEEEEEEEEEEE00EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE00EEEEEEEEEEE
      EEEEEEEEEEEEEEEEEEE00EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE00EEEEEEEEEEE
      EEEEEEEEEEEEEEEEEEE00EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE00EEEEEEEEEEE
      EEEEEEEEEEEEEEEEEEE00EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE00EEEEEEEEEEE
      EEEEEEEEEEEEEEEEEEE000000000000000000000000000000000}
    Spacing = 15
  end
end