Marco Cantù 1998, Mastering Delphi 4

Project: APPSOUND.DPR


Project Structure


APPSOUND.DPR

program AppSound;

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

{$R *.RES}

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

APPSNDF.PAS

unit AppSndF;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
  public
    procedure AppMini (Sender: TObject);
    procedure AppRestore (Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

uses
  MmSystem;

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMinimize := AppMini;
  Application.OnRestore := AppRestore;
end;

procedure TForm1.AppMini (Sender: TObject);
begin
  PlaySound ('Minimize', 0, snd_Async);
end;

procedure TForm1.AppRestore (Sender: TObject);
begin
  PlaySound ('RestoreUp', 0, snd_Async);
end;

end.

APPSNDF.DFM

object Form1: TForm1
  Left = 209
  Top = 112
  Width = 413
  Height = 221
  Caption = 'AppSound'
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 88
    Top = 64
    Width = 233
    Height = 65
    Alignment = taCenter
    Caption = 'Minimize and restore application to hear standard Windows sounds'
    Font.Charset = ANSI_CHARSET
    Font.Color = clBlack
    Font.Height = -16
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
    WordWrap = True
  end
end


Copyright Marco Cantù 1998