Click here to Skip to main content
16,008,010 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Implementing SMTP in MFC Pin
Joe Woodbury3-Apr-06 20:00
professionalJoe Woodbury3-Apr-06 20:00 
AnswerRe: Implementing SMTP in MFC Pin
Hamid_RT3-Apr-06 21:12
Hamid_RT3-Apr-06 21:12 
QuestionWNetAddConnection2() Pin
shadrach_india3-Apr-06 19:01
shadrach_india3-Apr-06 19:01 
QuestionCMenu owner Drawing Pin
Naveen3-Apr-06 18:32
Naveen3-Apr-06 18:32 
AnswerRe: CMenu owner Drawing Pin
Hamid_RT3-Apr-06 19:15
Hamid_RT3-Apr-06 19:15 
AnswerRe: CMenu owner Drawing Pin
Ștefan-Mihai MOGA4-Apr-06 0:11
professionalȘtefan-Mihai MOGA4-Apr-06 0:11 
QuestionTimers Pin
chetan2101833-Apr-06 17:53
chetan2101833-Apr-06 17:53 
AnswerRe: Timers Pin
Nibu babu thomas3-Apr-06 18:25
Nibu babu thomas3-Apr-06 18:25 
chetan210183 wrote:
The Problem now i am facing is, when the file gets full, i am trying to display error message and stop the timer. But Timer is not getting stopped by KillTimer().Timer continues in the running state.


This is because you are setting the timer again in OnClickStart. Why are you doing this? You don't have to set it again and again as you are doing now.


chetan210183 wrote:
void CMyDlg::OnClickStart()
{
fp = fopen(file_name,"a");
if (NULL == fp)
{
MessageBox ("Error Writing File",NULL, MB_OK|MB_ICONSTOP);
KillTimer(m_nTimer);
}
m_nTimer = SetTimer(1, 100, NULL);
fprintf(fp,"%d\n",status);
}


Look at the lines in bold. You first Kill the timer and then again you set it. So how can you expect it to stop at all.


chetan210183 wrote:
void CMyDlg::OnTimer(UINT nIDEvent)
{
OnClickStart();
CDialog::OnTimer(nIDEvent);
}


Again inside the timer function you are calling OnClickStart which in turn again sets the timer.


What you should be doing is...
void CMyDlg::OnClickStart() 
{
   //set the timer here. Nothing else!
   m_nTimer = SetTimer(1, 100, NULL);
}


And now inside the timer function
void CMyDlg::OnTimer(UINT nIDEvent) 
{
   //write your timer related code here. Not anywhere else!
   fp = fopen(file_name,"a");
   if (NULL == fp)
   {
       MessageBox ("Error Writing File",NULL, MB_OK|MB_ICONSTOP);
       KillTimer(m_nTimer);
   }
}


Note: Well this is just guess work about what you want to do. You will have to modify the above procedure based on your requirements


Nibu thomas
Software Developer

GeneralRe: Timers Pin
chetan2101833-Apr-06 18:46
chetan2101833-Apr-06 18:46 
GeneralRe: Timers Pin
Nibu babu thomas3-Apr-06 18:52
Nibu babu thomas3-Apr-06 18:52 
GeneralRe: Timers Pin
chetan2101833-Apr-06 18:59
chetan2101833-Apr-06 18:59 
GeneralRe: Timers Pin
Nibu babu thomas3-Apr-06 19:02
Nibu babu thomas3-Apr-06 19:02 
AnswerRe: Timers Pin
Laxman Auti3-Apr-06 18:28
Laxman Auti3-Apr-06 18:28 
GeneralRe: Timers Pin
Nibu babu thomas3-Apr-06 18:33
Nibu babu thomas3-Apr-06 18:33 
AnswerRe: Timers Pin
Anilkumar K V3-Apr-06 20:09
Anilkumar K V3-Apr-06 20:09 
Questionread and write email in lotus notes Pin
rcao3-Apr-06 17:20
rcao3-Apr-06 17:20 
Questionusing process to look for hwnd Pin
zt97883-Apr-06 17:10
zt97883-Apr-06 17:10 
AnswerRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 17:46
Stephen Hewitt3-Apr-06 17:46 
GeneralRe: using process to look for hwnd Pin
zt97883-Apr-06 19:13
zt97883-Apr-06 19:13 
GeneralRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 19:16
Stephen Hewitt3-Apr-06 19:16 
GeneralRe: using process to look for hwnd Pin
zt97883-Apr-06 19:43
zt97883-Apr-06 19:43 
GeneralRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 19:53
Stephen Hewitt3-Apr-06 19:53 
Questioncode like this. Pin
sting_lee3-Apr-06 16:27
sting_lee3-Apr-06 16:27 
AnswerRe: code like this. Pin
Rick York3-Apr-06 17:44
mveRick York3-Apr-06 17:44 
GeneralRe: code like this. Pin
toxcct3-Apr-06 21:56
toxcct3-Apr-06 21:56 

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.