468,107 Members | 1,382 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

How to looping with Timer?

Dear all,
I am a student making a MS Form application in C++. I would ask a question about "Timer". Sample code which I am developing is below.

private: System::Void buttonStart_Click(System::Object^ sender, System::EventArgs^ e){
for (int i=1; i<=10; i++){
String^ strValue;
int interval=1000; // time interval of looping equal to 1s
SetTimer(timer1, interval, NULL);
do {
this->textBox->Text = strValue;
while(TimerFlag = 0);
TimerFlag = 0;

private: System::Void FunctionName(String^ *strValue){
*strValue = "Something which could change in each time of above looping";

private: System::Void OnTimer(int timerId){
if(timerId = 1){
TimerFlag = 1;
HWND hwnd = NULL;

Compiling errors are
1. SetTimer doesn't take 3 arguments
2. Kill timer doesn't take 1 arguments

How should I input the arguments and how should I correctly looping with 1s interruption? Please help me!

Thank you very much in advance.

Jul 9 '08 #1
2 1727
1,275 Expert 1GB
If you are free to use any libraries then try to use ACE.
It has a timer also in it...

Jul 9 '08 #2
Expand|Select|Wrap|Line Numbers
  1. while(TimerFlag = 0);
This will always fail to execute as

Expand|Select|Wrap|Line Numbers
  1. TimerFlag = 0
will always be false.

Expand|Select|Wrap|Line Numbers
  1. if(timerId = 1)
This line isuseless unless you actually want to assing 1 to timerId, but the braces and the if are not neccessary.

I think you stick with the basics for now.

You need to get with your instructor and let him or her know you need some one on one time with a tutor.

Somethings are quicker when your not strugling with the slow communication of the internet.

Also, a tutor can see whether this code took you a few seconds to write or a few days, and they can imediately address the areas that you should be focusing on.

Expand|Select|Wrap|Line Numbers
  1. if( SomeValue == 1) 
Notice the second '='?
Jul 12 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

45 posts views Thread by Trevor Best | last post: by
2 posts views Thread by John David Thornton | last post: by
12 posts views Thread by Gina_Marano | last post: by
reply views Thread by Jim S | last post: by
8 posts views Thread by =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.