Solved

Setting timer for a method

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 114
Host to IP 7 80
Expand macro to ask for filename column 8 37
MaxSpan challenge 9 104
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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