On Timer
-
i jus wanted to know how do i show the values in the edit box when i use the timer. this value should get updated every second. till a range. for example till 100. in the edit box it should display from 1 to 100. actually i am using a for loop to iterate te value till 100. but only the last value is printing. i have set the timer lik this OnButton Function: &
SetTimer(1,100,NULL);
and on the OnTimer function:PCString str1; if (nIDEvent==1) { for(int i=0;i<=100;i++) { str1.Format("%d",i); if(i%2==0) { m_listbox.AddString(str1); m_edit.SetWindowText(str1); } } }
i know its a simple mistake. but i am not being able to figure out. -
i jus wanted to know how do i show the values in the edit box when i use the timer. this value should get updated every second. till a range. for example till 100. in the edit box it should display from 1 to 100. actually i am using a for loop to iterate te value till 100. but only the last value is printing. i have set the timer lik this OnButton Function: &
SetTimer(1,100,NULL);
and on the OnTimer function:PCString str1; if (nIDEvent==1) { for(int i=0;i<=100;i++) { str1.Format("%d",i); if(i%2==0) { m_listbox.AddString(str1); m_edit.SetWindowText(str1); } } }
i know its a simple mistake. but i am not being able to figure out. -
i jus wanted to know how do i show the values in the edit box when i use the timer. this value should get updated every second. till a range. for example till 100. in the edit box it should display from 1 to 100. actually i am using a for loop to iterate te value till 100. but only the last value is printing. i have set the timer lik this OnButton Function: &
SetTimer(1,100,NULL);
and on the OnTimer function:PCString str1; if (nIDEvent==1) { for(int i=0;i<=100;i++) { str1.Format("%d",i); if(i%2==0) { m_listbox.AddString(str1); m_edit.SetWindowText(str1); } } }
i know its a simple mistake. but i am not being able to figure out.might be the followig code work as u desire. Try it and let me know whether it worked or not. ( i know its in win32 and you are using MFC but i know u can make to use it )
#define ONE_SEC 1
int i=0;case WM_INITDIALOG:
SetTimer(hdlg,ONE_SEC,10*100,NULL);break;
case WM_TIMER:
if (wParam == ONE_SEC)
{
SetDlgItemInt(hdlg,IDC_EDIT1,i++,FALSE);
}
break;[ Screen Capture ][ Tool Tip ][ Muliple Desktops ][Greeting Card ]
-
i jus wanted to know how do i show the values in the edit box when i use the timer. this value should get updated every second. till a range. for example till 100. in the edit box it should display from 1 to 100. actually i am using a for loop to iterate te value till 100. but only the last value is printing. i have set the timer lik this OnButton Function: &
SetTimer(1,100,NULL);
and on the OnTimer function:PCString str1; if (nIDEvent==1) { for(int i=0;i<=100;i++) { str1.Format("%d",i); if(i%2==0) { m_listbox.AddString(str1); m_edit.SetWindowText(str1); } } }
i know its a simple mistake. but i am not being able to figure out.You have not specified what is not working as expected, so please tell us what you want to do! What do you need a timer for this?
-
You have not specified what is not working as expected, so please tell us what you want to do! What do you need a timer for this?
i dont know if there is another way other than timer to increment the value in a edit box every sec or millisecond. the problem is it only shows the last number that is 100. i have to show it from 1 to 100.
-
i dont know if there is another way other than timer to increment the value in a edit box every sec or millisecond. the problem is it only shows the last number that is 100. i have to show it from 1 to 100.
ok, if I understand you correc, you want to increment the value of an edit box every 1 second, starting from 0 going to 100. If that is the case, then a timer is the way to go. Your timer needs to be set up for 1000ms(1sec). You have set it up for 100ms only. SetTimer(1,1000,NULL); Now create a member variable for your edit control of type "value" and set its datatype to int. Lets call it "value". In OnTimer: if (nIDEvent==1) { if(value < 100) { value++; UpdateData(FALSE); } }
-
ok, if I understand you correc, you want to increment the value of an edit box every 1 second, starting from 0 going to 100. If that is the case, then a timer is the way to go. Your timer needs to be set up for 1000ms(1sec). You have set it up for 100ms only. SetTimer(1,1000,NULL); Now create a member variable for your edit control of type "value" and set its datatype to int. Lets call it "value". In OnTimer: if (nIDEvent==1) { if(value < 100) { value++; UpdateData(FALSE); } }
thanks a lot dude..