Click for more info
CopyGenie




   Entire Site      Advanced 

Forum    Newest Components   Top 20 Downloads   Edit Comps/Apps   Tips   Chat   Books
Play a sound on mouse enter
    You've seen those installs that play sounds when you mouse over a button, this is all you have to do

unit Unit1;

interface

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

type
 TForm1 = class(TForm)
   Button1: TButton;
   procedure FormCreate(Sender: TObject);
 private
   { Private declarations }
   procedure WndProc(var Message : TMessage); override;
 public
   { Public declarations }
 end;

var
 Form1: TForm1;
 FSoundFile : String;

implementation

{$R *.DFM}

procedure TForm1.WndProc(var Message : TMessage);
begin
 if Message.LParam = Longint(Button1) then
 begin
  if (Message.Msg = CM_MOUSELEAVE) then
    sndPlaySound(nil, snd_Async or snd_NoDefault);
  if (Message.Msg = CM_MOUSEENTER) then
    sndPlaySound(pchar(FSoundFile), snd_Async or snd_NoDefault);
 end;
inherited WndProc(Message);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FSoundFile := 'C:\Windows\Media\Ding.wav';
end;

end.
Author: k3nx

Back Insert New Tip    Home