Hi, how to Set a Timer through a other funktion.
I only can set the timer with result in the WINPROC.
I tryed to call the Settimerfunktion with NULL als hwnd, but then the timer isnt seted, so how to set the timer ?

WndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD


INVOKE SetTimer, hWnd, 1, 1000, NULL ; work !!!!!!!!!!!!!!!!
WndProc ENDP

otherfunktion PROC

INVOKE SetTimer, NULL, 1, 1000, NULL ; doesnt work !!!!!!!!!!!!!!!!!!!! how to call this funktion, that it work ?

otherfunktion ENDP
Posted on 2003-03-01 03:52:40 by Forginforcer
I think you have to set the timer like this:

invoke SetTimer.....
Posted on 2003-03-01 04:00:33 by Vortex
I did, but the I have the problem with the settimer call in the otherfunktion funktion...
Posted on 2003-03-01 04:02:36 by Forginforcer
If you want to associate your main window with the timer,try to use hWnd instead of NULL.
Posted on 2003-03-01 04:08:55 by Vortex
@Vortex thanks for your attention...

i already tryed, but in the funktion, i call settimer, i havn't hWnd.
do you know a solution
Posted on 2003-03-01 04:12:39 by Forginforcer

INVOKE SetTimer........<-----Try to put here the second SetTimer function.
INVOKE UpdateWindow, hwnd
INVOKE GetMessage, ADDR msg,NULL,0,0

Posted on 2003-03-01 04:17:04 by Vortex
Last param in SetTimer is for addr of function that is called
on timer.
Posted on 2003-03-01 04:20:09 by The Svin
Hi at all.

I dont understand your code as well.
im a bloody beginner. I'm programming youst a few month.
Posted on 2003-03-01 04:21:18 by Forginforcer

invoke INVOKE SetTimer, NULL, 1, 1000, offset OnTimerProc
OnTimerProc proc a1,a2,a3,a4

;do here what do you want when the timer "beeps" :)

OnTimerProc endp
Posted on 2003-03-01 04:31:06 by The Svin
The Svin has right,you must to specify the function name when you are setting the timer.

The SetTimer function creates a timer with the specified time-out value.

UINT SetTimer(

HWND hWnd, // handle of window for timer messages
UINT nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // address of timer procedure



Identifies the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.


Specifies a nonzero timer identifier. If the hWnd parameter is NULL, this parameter is ignored.


Specifies the time-out value, in milliseconds.


Points to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc.
If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. The hwnd member of the message's MSG structure contains the value of the hWnd parameter.

Posted on 2003-03-01 04:32:34 by Vortex
I just want to stress that in the case the function would be call back function and need to be written with 4 params frame.
Otherwise you'd have problems.
Posted on 2003-03-01 04:46:37 by The Svin
Ohhhhhhh ! THX
Posted on 2003-03-01 04:54:11 by Forginforcer
I've just written an example for you.
The app doesn't haveany window at all, though it uses
2 timers and two relative timer's procs
One to make some sound
The other to shut down the app when set time ellapsed.

BTW: I don't think the topic fits to this section.
But it's up to moderators of course.
Posted on 2003-03-01 05:33:51 by The Svin
Thx !
The sounds are very funny.
Posted on 2003-03-01 05:37:51 by Forginforcer
how to kill teh timer ?
i tryed "invoke KillTimer,0, 0"
Posted on 2003-03-01 06:01:49 by Forginforcer
When you SetTimer save returned value from the
func and use it as the second param to KillTimer
Posted on 2003-03-01 07:31:15 by The Svin
How I can get the returned value ?
I already read e lot ! - I Think i read crap, where i can get a got tut ?
i thougt, if i set a timer with the ID 0 then can kill it with the ID 0.....
Posted on 2003-03-01 08:09:58 by Forginforcer
RTFM!!! Open Win32.hlp on SetTimer and KillTimer
and carefully RTFM it's just a few lines.
Returned value is value you have in eax after
SetTimer call.
If you use SetTimer with 0 as the first param - ID is in return value. And ID you specifyed - is totaly ignored.
Save it in some var and use in KillTimer when needed.
I don't know what do you mean by e-lot but all this
just a few lines in Win32.hlp about KillTimer function.
Posted on 2003-03-01 08:18:00 by The Svin
mist !
I cant delete the timer !
Why ???
look i have the follwoing funktion:

INVOKE SetTimer, hwnd, 10, 1000, offset OnTimer1
mov TimerID, EAX

OnTimer1 proc a1,a2,a3,a4

invoke KillTimer, hwnd, TimerID
invoke KillTimer, hwnd, 10

OnTimer1 ENDP

Need Help !
Posted on 2003-03-01 10:07:36 by Forginforcer
I've said that your ID specified in SetTimer is ignored
when you don't use hWnd and you have to use retrurned value as ID.
Yet you do in reverse - using your ID and not using returnd value:

tmrID dd ?
;to set timer and save it's ID
invoke SetTimer,0,0,1000,offset OnTimerProc
mov tmrID,eax ;!!!!Save returned value!!!

;to kill timer use the saved ID

invoke KillTimer,0,tmrID ;!!!Use the returned from ;SetTimer value!!!!

Red Forginforcer, I think you have to learn the asm language itself first, then start with API.

'Cause if you don't understand some basics like what is
returned value and how to save it - you'll have problems and missunderstanding on every step.

bitRake: Please, think about removing this thread to
Main section. I doesn't seem fit here.
Posted on 2003-03-01 10:22:27 by The Svin