Archived

This topic is now archived and is closed to further replies.

Erzengeldeslichtes

WinAPI Timer being fussy...

Recommended Posts

I have a timer that's supposed to go off every second while the application patiently waits for any kind of message to tell it it's in use (the timer is only to refresh the screen--1 second is all that is needed for this particular app). When I first start up the application it works flawlessly, indefinitly. Even when I alt+tab to or click on another open application it continues to update the window. However, if I open or close another application the timer suddenly stops and simply won't turn back on--I have a key that kills the previous timer and starts a new one, but the timer still doesn't ping the program. Even if the program is in the foreground or I kill the other application, the timer still stops functioning (other messages cause it to update, just not the timer). What could be wrong?
//g_hwndMainWindow is set as the newly created window, if it's null the app quits.

//in header:

const int TIMER_ONE = 1;//I've tried many other numbers just to make sure.

//In initialization of the application:

SetTimer(g_hwndMainWindow, TIMER_ONE, 1000, NULL);
//After drawing a frame:

WaitMessage();
//If timer activation key is pressed:

KillTimer(g_hwndMainWindow, TIMER_ONE);
SetTimer(g_hwndMainWindow, TIMER_ONE, 1000, NULL);
//Uninitializer:

KillTimer(g_hwndMainWindow, TIMER_ONE);
[edited by - Erzengeldeslichtes on January 5, 2004 7:51:17 AM] [edited by - Erzengeldeslichtes on January 5, 2004 8:03:34 AM]

Share this post


Link to post
Share on other sites
Uh? WinAPI Documentation (and intellisense) says the second parameter is an unsigned int. Not to mention if it DID want a pointer or a referance the compiler would have complained that I was passing a constant int into it. Even if it took the UINT passed to it and used it as a pointer, I'd get all sorts of access violations when I run the code, but I don't.

//Intellisense function info:

UINT SetTimer(HWND hWnd, UINT nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc)


Besides, even if I don't actually have the proper ID for the timer, it would still be sending the timer messages. I just wouldn't be able to clean up after myself.


Edit: Okay, I see in my OTHER version of the SDK (the newer one that I haven't linked to in this app yet) that it IS a UINT_PTR, so you are correct. However, I can tell you that's not the problem because the ones I link to say it's just a UINT. (I should probably update that)

Edit 2: Well that's interesting. I linked to the latest SDK but intellisense still says it's a UINT not a UINT_PTR and it still compiles without complaints. Hm.

[edited by - Erzengeldeslichtes on January 5, 2004 8:16:55 AM]

[edited by - Erzengeldeslichtes on January 5, 2004 8:19:40 AM]

Share this post


Link to post
Share on other sites
Thanks for clearing that up Dr. Pizza.

So no one has any ideas why Windows XP (haven''t tried it on other windows plat would prevent my application from either running or recieving timer calls when another application opens or closes?

Share this post


Link to post
Share on other sites