Timer
-
Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock
-
Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock
Check out
SetTimer()
and WM_TIMER "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr -
Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock
Basically, use liek this, with ON_WM_TIMER() SetTimer(1, 3600 000, NULL); 3600 000 here indicates an hour... it's in msec. so the code would look like..... int iTimer = 0; //global variable to count time //this will get invoked every hour YourClass::OnTimer(UINT nIDEvent) { iTimer=iTimer+1; if(iTimer == 12){ //do your processing.... } if (iTimer == 24){ iTimer = 0; } }//end of fn hope this helps dude. jey
-
Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock
For this waitable timers are best, because (as opposite to WM_TIMER) they do not work only with relative time, but also with absolute time and therefore fire at the right moment even if the machine was down in the mean time, the clock was adjusted or something else. Check out CreateWaitableTimer() for more info about waitable timers. -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )
-
Basically, use liek this, with ON_WM_TIMER() SetTimer(1, 3600 000, NULL); 3600 000 here indicates an hour... it's in msec. so the code would look like..... int iTimer = 0; //global variable to count time //this will get invoked every hour YourClass::OnTimer(UINT nIDEvent) { iTimer=iTimer+1; if(iTimer == 12){ //do your processing.... } if (iTimer == 24){ iTimer = 0; } }//end of fn hope this helps dude. jey
Thanks very much for the direction. I don't suppose you have some small source files you could send me. I'm new to programming and I have a hard time putting the code in the right place. usually when I see the source files I can just duplicate what was done before and make it work. Thank again. Mavrock my email is stonematthies@hotmail.com