Solved

Setting timer for a method

Posted on 2002-07-10
1
211 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 103
Generic progress indicator 6 117
has22 challenge 11 96
canBalance challenge 34 87
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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