| | |
MFC Countdown Timer
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
I am writing a MFC application and need to have the program pause for a few seconds. I am trying to use the OnTimer event and am having troubles. The following code causes the program to freeze and stop responding
However if I add the following it works fine.
In both of these examples the program is suppose to wait 5 seconds before continuing. Also note that m_iCount is suppose to incrament everytime the ID_TEST_TIMER event is called. Any suggestions on what I am doing wrong and can do to fix it?
c Syntax (Toggle Plain Text)
m_iCount = 0; SetTimer(ID_TEST_TIMER, 1000, NULL); while(m_iCount <= 5) { }
However if I add the following it works fine.
c Syntax (Toggle Plain Text)
m_iCount = 0; SetTimer(ID_TEST_TIMER, 1000, NULL); while(m_iCount <= 5) { CString x; x.Format("%d",m_iCount); MessageBox(x); }
In both of these examples the program is suppose to wait 5 seconds before continuing. Also note that m_iCount is suppose to incrament everytime the ID_TEST_TIMER event is called. Any suggestions on what I am doing wrong and can do to fix it?
Thanx,
Atrus
Atrus
C Syntax (Toggle Plain Text)
while(m_iCount <= 5) { }
why are you making it so difficult ? If you goal is for the program to pause for 5 second, just call Sleep() function. No need for that timer.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Ok, so here's a spin off of the previous. If I wanted the user to only have say 20 seconds to enter text in an edit box before it grayed out, how would I go about that? causes the program to pause, so what would I use?
c Syntax (Toggle Plain Text)
Sleep()
Thanx,
Atrus
Atrus
•
•
•
•
Ok, so here's a spin off of the previous. If I wanted the user to only have say 20 seconds to enter text in an edit box before it grayed out, how would I go about that?causes the program to pause, so what would I use?c Syntax (Toggle Plain Text)
Sleep()
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Tkinter Countdown Timer problems. (Python)
- Pause/Restart Countdown Timer Question (VB.NET)
- Countdown Timer (VB.NET)
Other Threads in the C Forum
- Previous Thread: DefWindowProc
- Next Thread: Calling C function from MATLAB
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop initialization input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux list lists looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation overwrite owf pdf pointer pointers posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprogramming standard strchr string suggestions systemcall test testing threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi






