Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Timer.OnTimer event

0 views
Skip to first unread message

Peggy Schaefer

unread,
May 28, 1999, 3:00:00 AM5/28/99
to
I'm loading over 50 graphics and separate *.wav files from a dll and I need
to slow down the sound files to synchronize with the graphics. The
timer.ontimer event will be different for each *.wav file. I want to create
the timer and it's OnTimer events from the procedure that opens the graphics
file. I can create the timer fine it's the writing of the Timer.OnTimer
event from within another procedure that has me stumped. My code is
something like this:

Timer := TTimer.Create(Self)
Timer.Interval := 100
Timer.OnTimer := ResSt := TResourceStream.Create(ResDLLMod, 'Wav3', pchar
('WAVE'));
sndPlaySound(ResSt.Memory, SND_MEMORY or SND_SYNC);
ResSt.free;

But this does not work. By now you can probably tell I'm a real novice so
if you'd be VERY specific with your reply, I'd really appreciate it.

Peggy


Christo Crause

unread,
May 30, 1999, 3:00:00 AM5/30/99
to
In article <7im8kd$9m7$1...@birch.prod.itd.earthlink.net>, pegg...@earthlink.net
says...

>I can create the timer fine it's the writing of the Timer.OnTimer
>event from within another procedure that has me stumped. My code is
>something like this:
>
>Timer := TTimer.Create(Self)
>Timer.Interval := 100
>Timer.OnTimer := ResSt := TResourceStream.Create(ResDLLMod, 'Wav3', pchar
> ('WAVE'));
> sndPlaySound(ResSt.Memory, SND_MEMORY or SND_SYNC);
> ResSt.free;
>
>But this does not work.

The OnTimer property is declared as type TNotifyEvent. TNotifyEvent is defined
as follows:

type TNotifyEvent = procedure (Sender: TObject) of object;

This means that you must write a procedure that accepts one parameter (of type
TObject) that contains your code eg.:

type
TForm1 = class(TForm)
private
public
procedure MyTimerHandler(sender: TObject);
end;

var
Form1: TForm1;
Timer : TTimer;

implementation

{$R *.DFM}

procedure TForm1.MyTimerHandler(sender : TObject);
var ResSt : TResourceStream;
begin
ResSt := TResourceStream.Create(ResDLLMod, 'Wav3', pchar('WAVE'));


sndPlaySound(ResSt.Memory, SND_MEMORY or SND_SYNC);
ResSt.free;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Timer := TTimer.Create(Self);
Timer1.OnTimer := MyTimerHandler;
end;

You must also remember to free the timer when you are finished using it.

--
Christo Crause
Thermal Separations Research
University of Stellenbosch
South Africa


0 new messages