Solved

Timer in VC++

Posted on 2001-07-08
1
1,098 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
[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:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

695 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