Solved

Timer in VC++

Posted on 2001-07-08
1
1,086 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
Powershell based monitoring system 2 127
Replacement selected text 2 47
Detect CR LF to each line 12 137
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 (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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 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

19 Experts available now in Live!

Get 1:1 Help Now