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
>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