Skip to main content
gamedev.net
🔒 Locked

Setting a Timer

Started by King 1 reply 1.2k views
Gladiator
Gladiator
...

void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
{
// move your bitmap and draw it on the screen.. or whatever
}

// ..in WM_CREATE include the following code..

// create a timer that will call the callback function every 50 milisecs... the hWnd parameter is your main window''s handle

SetTimer(hWnd, 1000, 50, TimerProc);

...

// somewhere in your code as in WM_DESTROY
KillTimer(hWnd, 1000);

.. that''s about it..

one thing to notice... you can call your SetTimer() function as follows...

SetTimer(hWnd, 100, 50, NULL);

and instead providing a call function for the timer, you can trap the WM_TIMER message and move your bitmap in there.. just an idea... whichever you prefer.. for more info take a look at win32.hlp..

Good Luck!

..-=ViKtOr=-..
King
King
Thank you so much, I tried to do something like this, but it doesn't work, could you tell me why and what would you do?

case WM_TIMER:
InvalidateRect( hwnd, NULL, FALSE );
count = GetTickCount( );
SetTimer( hwnd, 10, te, NULL );

if( count < te )
{
expos = expos + 15;
}

expos is the position of the bitmap, oh and te is set to 60.

Edited by - King on 3/23/00 9:58:35 PM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.