Solved

Timer in VC++

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 71
Separate files macro - Errors on larger data set 18 73
move a line in eclipse 3 109
ffmpeg - "rtsp://...... Operation not permitted" 4 89
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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