Are you passing a valid window handle or timer ID? Some code would help.
--
Dave Nottage (TeamB)
I do believe that it is necessary to process Windows messages in order for
SetTimer to work. Does your application make a call to GetMessage,
PeekMessage, or DispatchMessage?
Of course, I could be wrong.
- Brian
It's not necessary if using a TimerProc callback function.
--
Dave Nottage (TeamB)
Give this a try...
program Project2;
{$APPTYPE CONSOLE}
uses
Windows;
var
TimerId: UINT;
procedure TimerProc( Handle: HWND; uMsg: UINT; idEvent: UINT; dwTime:
DWORD ); stdcall;
begin
KillTimer( 0, TimerId );
MessageBox( 0, 'Yo!', 'Yo!', MB_OK );
end;
procedure Pump;
var
M: TMsg;
begin
while GetMessage( M, 0, 0, 0 ) do
DispatchMessage( M );
end;
begin
TimerId := SetTimer( 0, 0, 100, @TimerProc );
Readln;
// Pump;
end.
...and then this...
program Project2;
{$APPTYPE CONSOLE}
uses
Windows;
var
TimerId: UINT;
procedure TimerProc( Handle: HWND; uMsg: UINT; idEvent: UINT; dwTime:
DWORD ); stdcall;
begin
KillTimer( 0, TimerId );
MessageBox( 0, 'Yo!', 'Yo!', MB_OK );
end;
procedure Pump;
var
M: TMsg;
begin
while GetMessage( M, 0, 0, 0 ) do
DispatchMessage( M );
end;
begin
TimerId := SetTimer( 0, 0, 100, @TimerProc );
// Readln;
Pump;
end.
Have a good weekend, Brian
That'll teach me to read all of the help on SetTimer.
program Project1;
{$APPTYPE CONSOLE}
uses
Windows;
var
TimerId: UINT;
procedure TimerProc(Handle: HWND; uMsg: UINT; idEvent: UINT; dwTime:DWORD);
stdcall;
begin
if Integer(KillTimer(0, idEvent)) <> 0 then
MessageBox(0, 'Yo!', 'Yo!', MB_OK);
TimerId := 0;
end;
procedure Pump;
var
M: TMsg;
begin
while (TimerID <> 0) and GetMessage(M, 0, 0, 0) do
DispatchMessage(M);
end;
begin
TimerId := SetTimer(0, 1, 100, @TimerProc);
Pump;
Readln;
end.
--
Dave Nottage (TeamB)
Wrong. The callback is fired my the message loop code instead of putting
a WM_TIMER message into the queue. In an application that has no message
loop one has to use a secondary thread as timer.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be