Click here to Skip to main content
15,915,319 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
Steen Krogsgaard5-Sep-01 21:56
Steen Krogsgaard5-Sep-01 21:56 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
RobJones6-Sep-01 6:20
RobJones6-Sep-01 6:20 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
<k>Andreas Hoheisel6-Sep-01 8:48
<k>Andreas Hoheisel6-Sep-01 8:48 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
RobJones6-Sep-01 9:19
RobJones6-Sep-01 9:19 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
Steen Krogsgaard6-Sep-01 22:17
Steen Krogsgaard6-Sep-01 22:17 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
A.R.6-Sep-01 11:30
A.R.6-Sep-01 11:30 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
RobJones6-Sep-01 11:51
RobJones6-Sep-01 11:51 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
A.R.6-Sep-01 14:40
A.R.6-Sep-01 14:40 
Rob,

It seems that you have some re-entrancy code and a very bad function call. You are calling your function (as I said in my previous message) inside of your function, creating a recursive call with no exit at all. Let me be more specific ...
In your function OnTimer() you have a line at the end that says "CAdd1Dlg::OnTimer(nIDEvent)" and this is the horrible bug. Instead you have to call the base method, i.e. CDialog::OnTimer(nIDEvent).

On the other hand, the timer has been set to signal every one second, and in the code where you are handling this event, there is no way to stop the messaging system sending the signal every one second, and here is where meanwhile you are decrementing your variable and formatting your display, another call has been made and so on.
One good rule is if your timer's handler do a lot of work and the timer's period is short, you have to tell the messaging system "give me a break". So in your code, you can use something like:

void CAdd1Dlg::OnTimer(UINT nIDEvent){
switch (nIDEvent){
case IDC_S_TIMER1:
KillTimer(IDC_S_TIMER1); // Stop the timer
//decrement the count
iS --;
//format and display the count
m_ctlTime1.Display(iS,iM,iH,iD,(CString)m_strTime1="%D:%H:%M:%S");
UpdateData(FALSE);
SetTimer(IDC_S_TIMER1, 1000, NULL); // Restart the timer
break;
}
//UpdateData(FALSE); <=== Make this call before.
//CAdd1Dlg::OnTimer(nIDEvent) <=== Dead | X| OOPS! This is the bad guy in your code
CDialog::OnTimer(nIDEvent); // Use this instead.
}

I hope this helps

Au revoir.
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
6-Sep-01 15:13
suss6-Sep-01 15:13 
GeneralRe: Error when firing SetTimer in a Modeless Dlg Pin
Steen Krogsgaard6-Sep-01 21:11
Steen Krogsgaard6-Sep-01 21:11 
QuestionWhat happened? :(( Pin
Cathy5-Sep-01 12:17
Cathy5-Sep-01 12:17 
AnswerRe: What happened? :(( Pin
Christian Graus5-Sep-01 13:38
protectorChristian Graus5-Sep-01 13:38 
GeneralRe: What happened? :(( Pin
Cathy6-Sep-01 6:27
Cathy6-Sep-01 6:27 
GeneralRe: What happened? :(( Pin
Christian Graus6-Sep-01 12:10
protectorChristian Graus6-Sep-01 12:10 
Generalcapturing OutputDebugStrings Pin
Steve The Plant5-Sep-01 11:02
Steve The Plant5-Sep-01 11:02 
GeneralRe: capturing OutputDebugStrings Pin
Tomasz Sowinski6-Sep-01 1:57
Tomasz Sowinski6-Sep-01 1:57 
GeneralRe: capturing OutputDebugStrings Pin
reiko6-Sep-01 18:39
reiko6-Sep-01 18:39 
GeneralRe: capturing OutputDebugStrings Pin
Mike Nordell7-Sep-01 10:59
Mike Nordell7-Sep-01 10:59 
QuestionHow to display image in View? Pin
Jerry Wang5-Sep-01 9:18
Jerry Wang5-Sep-01 9:18 
AnswerRe: How to display image in View? Pin
Chris Losinger5-Sep-01 10:32
professionalChris Losinger5-Sep-01 10:32 
AnswerRe: How to display image in View? Pin
Not Active5-Sep-01 10:42
mentorNot Active5-Sep-01 10:42 
GeneralBSTR parameter to Stored Procedure Pin
Bigge5-Sep-01 8:46
Bigge5-Sep-01 8:46 
GeneralRe: BSTR parameter to Stored Procedure Pin
Not Active5-Sep-01 10:26
mentorNot Active5-Sep-01 10:26 
GeneralRe: BSTR parameter to Stored Procedure Pin
Rashid Thadha5-Sep-01 11:52
Rashid Thadha5-Sep-01 11:52 
GeneralTooltips Pin
5-Sep-01 7:40
suss5-Sep-01 7:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.