Click here to Skip to main content
15,897,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to implement a time delay? Pin
ThatsAlok9-Jan-06 23:12
ThatsAlok9-Jan-06 23:12 
GeneralRe: how to implement a time delay? Pin
ewighell9-Jan-06 16:50
ewighell9-Jan-06 16:50 
GeneralRe: how to implement a time delay? Pin
Stephen Hewitt9-Jan-06 11:59
Stephen Hewitt9-Jan-06 11:59 
GeneralRe: how to implement a time delay? Pin
ewighell9-Jan-06 16:40
ewighell9-Jan-06 16:40 
GeneralRe: how to implement a time delay? Pin
Stephen Hewitt9-Jan-06 16:45
Stephen Hewitt9-Jan-06 16:45 
GeneralRe: how to implement a time delay? Pin
ewighell9-Jan-06 16:53
ewighell9-Jan-06 16:53 
GeneralRe: how to implement a time delay? Pin
Stephen Hewitt9-Jan-06 17:08
Stephen Hewitt9-Jan-06 17:08 
GeneralRe: how to implement a time delay? Pin
Stephen Hewitt9-Jan-06 18:21
Stephen Hewitt9-Jan-06 18:21 
Try code like this (instead of the AfxMessageBox call - since a message pump seems to be required):

UINT TimerId = SetTimer(NULL, 0/*Ignored*/, 5000, NULL);

MSG m;
BOOL bOk;
while ( (bOk=GetMessage(&m, NULL, 0, 0)) && bOk!=-1 )
{
    DispatchMessage(&m);
    if ( m.message==WM_TIMER && m.wParam==TimerId )
    {
        break;
    }
}

KillTimer(NULL, TimerId);


Caveat:
I don't really know what's going on or what you’re trying to do or the over all structure of your program so this is just a guess. I have hard coded a 5 second delay. You will be able to use the UI of the app during this time - You may want to simulate modality by putting a call to disable the main app window before and another to re-enable it after. 9 times out of 10, when you put a hard coded delay in a program your doing the wrong thing: How long do you wait? Will this be long enough on a slower machine? If you wait long enough for a slow machine are you "cheating" users with fast machines?

Steve
GeneralRe: how to implement a time delay? Pin
ewighell9-Jan-06 19:39
ewighell9-Jan-06 19:39 
GeneralRe: how to implement a time delay? Pin
Stephen Hewitt9-Jan-06 19:42
Stephen Hewitt9-Jan-06 19:42 
GeneralRe: how to implement a time delay? Pin
ewighell9-Jan-06 20:01
ewighell9-Jan-06 20:01 
GeneralRe: how to implement a time delay? Pin
Stephen Hewitt9-Jan-06 20:13
Stephen Hewitt9-Jan-06 20:13 
QuestionThe New Extension IDE - EXTEIDE Pin
EXTEIDE6-Jan-06 10:13
EXTEIDE6-Jan-06 10:13 
AnswerRe: The New Extension IDE - EXTEIDE Pin
David Crow6-Jan-06 10:47
David Crow6-Jan-06 10:47 
GeneralRe: The New Extension IDE - EXTEIDE Pin
Roland Pibinger7-Jan-06 2:18
Roland Pibinger7-Jan-06 2:18 
GeneralRe: The New Extension IDE - EXTEIDE Pin
Prakash Nadar7-Jan-06 5:04
Prakash Nadar7-Jan-06 5:04 
GeneralRe: The New Extension IDE - EXTEIDE Pin
#realJSOP8-Jan-06 3:09
professional#realJSOP8-Jan-06 3:09 
AnswerRe: The New Extension IDE - EXTEIDE Pin
Trollslayer8-Jan-06 3:53
mentorTrollslayer8-Jan-06 3:53 
QuestionCString, fstream with Visual Studio 2005 Pin
DanYELL6-Jan-06 9:28
DanYELL6-Jan-06 9:28 
QuestionRe: CString, fstream with Visual Studio 2005 Pin
David Crow6-Jan-06 9:34
David Crow6-Jan-06 9:34 
AnswerRe: CString, fstream with Visual Studio 2005 Pin
DanYELL6-Jan-06 10:37
DanYELL6-Jan-06 10:37 
QuestionRe: CString, fstream with Visual Studio 2005 Pin
David Crow6-Jan-06 10:45
David Crow6-Jan-06 10:45 
AnswerRe: CString, fstream with Visual Studio 2005 Pin
DanYELL6-Jan-06 11:08
DanYELL6-Jan-06 11:08 
AnswerRe: CString, fstream with Visual Studio 2005 Pin
DanYELL6-Jan-06 11:15
DanYELL6-Jan-06 11:15 
GeneralRe: CString, fstream with Visual Studio 2005 Pin
David Crow7-Jan-06 17:00
David Crow7-Jan-06 17:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.