Solved

Setting timer for a method

Posted on 2002-07-10
1
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

717 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