Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Two settimers at the same time

Dear experts,

I need to have two timers which time two different actions in my app.
Is it possible to have two timers at one time? If yes, how can I achieve this?

0
Aphroditus
Asked:
Aphroditus
1 Solution
 
bertpCommented:
yes, just use different IDs when setting up the timers.   parameters sent with the WM_TIMER message will tell you which timer the message is servicing
0
 
chensuCommented:
Yes, just use different timer IDs as bertp already said. See

http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/psdk/winui/timers_1voy.htm
0
 
elston_saCommented:
#define TIMER1 1
#define TIMER1 2

//SetTImer 1
SetTimer(
MainframeHandle, // handle to window
TIMER1,// timer identifier
100, // time-out value
NULL // timer procedure
);

//SetTImer 2
SetTimer(
MainframeHandle, // handle to window
TIMER2,// timer identifier
100, // time-out value
NULL // timer procedure
);

......Now overide the,

OnTimer( UINT nIDEvent );

function of Mainframe Class and put the following code

switch (nIDEvent)
{
  case TIMER1:
   //Action  One
 
  case TIMER2:
  //Action two
};
0
 
chensuCommented:
elston_sa's code is almost the same as the code shown on the page I provided.
0
 
AphroditusAuthor Commented:
Thanks! It works well...
Thanks to you too chensu. :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now