You are most likely right. The funciton (while uncommented) of AfxMessageBox(_T("Failed to create the main window!")); never be reached. Thus I called KillTimer somewhere in the program to kill ID_PLAYTIME_EVENT and there were no more Stack Overflow problems. But question again: How do the following codes work? Once this code being called and run, how does it exit the while loop? Is it the correct way to process the message queue? while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } From my tests, once the program runs to this code, the while loop will exit forever until exiting the entire program. Actually that is what I had expected so that some other codes can run on a multitasking windows such 2000. DJ