| | |
MFC Countdown Timer
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 |
* adobe ansi api array binarysearch centimeter changingto char character cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax database directory feet fflush fgets file floatingpointvalidation fork frequency function givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux highest histogram homework i/o inches infiniteloop input interest intmain() iso keyboard kilometer km linked linkedlist linux linuxsegmentationfault list locate looping lowest match meter microsoft mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition reversing scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard string suggestions systemcall unix urboc user voidmain() wab whythiscodecausesegmentationfault win32api windows.h windowsapi






