Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting timer for a method

Posted on 2002-07-10
1
Medium Priority
?
235 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 150 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

783 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