Solved

Timer in VC++

Posted on 2001-07-08
1
1,090 Views
Last Modified: 2013-11-20
I have to navigate from one screen to another. The first dialog should appear for 30 seconds and then go to second dialog. How can i achieve this in MFC? If i use Sleep(30000)the desired result is not achieved.
0
Comment
Question by:abalkur
1 Comment
 
LVL 1

Accepted Solution

by:
hakob earned 50 total points
ID: 6263841
Sleep(mlsec) will wait mlsec miliseconds before implementing next code, so it is not suitable for using in InitDialog and other message handlers.

More suitable is to use SetTimer(timerID,mlsec), which initializes the timer with ID=timerID. It sends WM_TIMER message to the window each mlsec. You can kill the timer using KillTimer(timerID).

How to use:


1. Add WM_TIMER Windows Message Handler to your window. This will add OnTimer(UINT nIDEvent ) function.

2. Add the code in it

  static int nRestTime = 1;

  if ( nRestTime-- == 0 )
  {
     KillTimer(nIDEvent);
//   And here add the code to
//   Destroy the first dialog
//   and create the second one
  }

3. Put
   
  SetTimer(1, 30000);

  into the window initialization function, where the first
  dialog is created. For example, If your first dialog
  is the main window, you can put it into its InitDialog
  function.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

920 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now