?
Solved

Timer in VC++

Posted on 2001-07-08
1
Medium Priority
?
1,103 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 150 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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 …
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.
Screencast - Getting to Know the Pipeline
Suggested Courses

850 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