Logo New book: Delphi 2007 Handbook
My blog in online
Delphi tech support service: support.marcocantu.com
Google
  Web www.marcocantu.com

Menu for Development

Site Menu
Delphi 2007 Handbook
Mastering Borland Delphi 2005
Essential Pascal
Essential Delphi
Buy Books Online
Code Repository
Newsgroups
White Papers
Tools
Conferences
Training
Delphi Links
Contact Marco

My Other Sites
Italian Site (www.marcocantu.it)
Developers Newsgroups Browser (dev.newswhat.com)
My town (www.piazzacavalli.net)
the delphi search
Wintech Italia (my company)

Breaking News
Buy Mastering Borland Delphi 2005 from Amazon
Free ebook: Mastering Delphi Update for Delphi 2006

Advertising
Home My Blog Books My Bookstore Development Links 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