Advertisement

VB DoEvents method in C++

Started by August 30, 2001 07:39 PM
1 comment, last by Khoals 23 years, 3 months ago
Ok, this is a real newbie question, but I''m not sure about it: In Visual Basic, there is a method called DoEvents that let''s Windows handle any incoming messages from other programs/hardware and still maintain control of your program. This is useful in infinite loops (like a game loop or something) where you don''t want the loop to end and still don''t want the system to crash because all of the resources are going towards performing the loop. My question is how do I do anything that works like DoEvents in C++. Do infinite loops even lock up the system in C++? Thanks in advance.
No, infinite loops don''t kill a C/C++ program. Of course, there''s no REAL infinite loop, what''d be the point? See winprog.org for some more information on basic windows programs in C/C++.

[Resist Windows XP''s Invasive Production Activation Technology!]
Advertisement
  bool Terminated = false;void DoEvents(){    MSG msg;    while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))    {        if(msg.message == WM_QUIT)        {            Terminated = true;            return;        }        TranslateMessage(&msg);        DispatchMessage(&msg);    }}  

This topic is closed to new replies.

Advertisement