Solved

Setting timer for a method

Posted on 2002-07-10
1
191 Views
Last Modified: 2013-11-20
Hi,

 I need to set a timer for a function to be executed(or called) every two seconds in a dialog based application. I need it to start for example when I click on a button and stop when I click on another button. If possible please provide me with the code or steps.

Thank you all
0
Comment
Question by:Mazen
1 Comment
 
LVL 1

Accepted Solution

by:
joakimf earned 50 total points
ID: 7145348
Use SetTimer and KillTimer, like this:
OnStartButton ()
SetTimer ( 1, 2000, NULL );

OnStopButton ()
KillTimer ( 1 );


Then you must create a handler for the WM_TIMER message:
void OnTimer(UINT nIDEvent)
//The nIDEvent contains the ID you set as the first parameter in SetTimer ().

Hope this helps...

/Joakim
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now