Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!purdue!bu-cs!mirror!mguyott From: mguyott@mirror.UUCP (Marc Guyott) Newsgroups: comp.windows.ms Subject: Re: sleep() in Windows Message-ID: <33509@mirror.UUCP> Date: 1 Dec 89 16:31:37 GMT References: <21446@usc.edu> <865@rna.UUCP> Reply-To: mguyott@prism.TMC.COM (Marc Guyott) Organization: Mirror Systems, Cambridge Mass. Lines: 42 >In article <21446@usc.edu> papa@pollux.usc.edu (Marco Papa) writes: >>Does anybody have a "quick and dirty" UNIX-like sleep() for Windows? This is one possible solution: ---- #define TIMER_ID 1 #define EXIT_CODE 0x4000 void FAR PASCAL Sleep(hWnd, wMilliSeconds) HWND hWnd; WORD wMilliSeconds; { MSG Msg; if (!SetTimer(hWnd, TIMER_ID, wMilliSeconds, NULL)) { MessageBox(GetActiveWindow(), "A call to SetTimer() in Sleep() failed.", "Fatal Error!", MB_SYSTEMMODAL | MB_OK); FatalExit(EXIT_CODE); } GetMessage(&Msg, hWnd, WM_TIMER, WM_TIMER); if (!KillTimer(hWnd, TIMER_ID)) { MessageBox(GetActiveWindow(), "A call to KillTimer() in Sleep() failed.", "Fatal Error!", MB_SYSTEMMODAL | MB_OK); FatalExit(EXIT_CODE + 1); } return; } ---- "All my life I always wanted to BE somebody. I see now I should have been more specific." Jane Wagner Marc Guyott mguyott@mirror.tmc.com {mit-eddie, pyramid, harvard!wjh12, xait}!mirror!mguyott Mirror Systems Cambridge, MA 02140 617/661-0777