Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2740
  • Last Modified:

Visual Basic "DoEvents" C++ equivalent...

Hi...

In the Visual Basic, have the
"Doevents" command...

What the equivalent in C++ ?

thanks...
0
masvmasv
Asked:
masvmasv
1 Solution
 
Toad224Commented:
while(action)
{
}
0
 
masvmasvAuthor Commented:
Thanks man...

Looking my code:

   for x = 1 to 10
       doevents
   next

in Borland C++ Builder:

   for( int x = 1; x <= 10; x++ )
        Application->ProcessMessages();

and in C/C++ (Visual C++) ?

Thanks
0
 
KangaRooCommented:
There is no real equivalent to that in C++. There may be equivalents in specific frameworks, like masvmasv showed for BC Builder, or others for, lets say, MFC or OWL.
It would be usefull if you specified which frameworks you are using.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
masvmasvAuthor Commented:
ok...

thanks

But if I have a infinit loop:

   while( true )
   {
   }

crash Windows ?
0
 
nimrodhCommented:
if you are using multithreading, you can use the SleepEx function.
The SleepEx function causes the current thread to enter a wait state until one of the following occurs:
An I/O completion callback function is called.
An asynchronous procedure call (APC) is queued to the thread.
The time-out interval elapses.
0
 
masvmasvAuthor Commented:
Do you dont understand...

I need force Windows execute events, if I have a infinite loop...

thanks
0
 
jhanceCommented:
There is no equivalent to the VB DoEvents call in VC++.  So you need to do it some other way.

No window in your application will process any Windows messages while your application is busy processing in a long running or infinite loop.  The best course of action is to code you app so that there are no long procedures in the main app's thread.  Any long or "forever" loops should be coded in a separate thread.  That way, Windows messages will still be processed even though your function is running for a long time.

If you cannot do it this way, a possible work around is to interrupt your loop periodically, setup a timer to signal you to restart the loop, and save some status information to permit you to restart the loop where you left off.  Then you can return to Windows.  When the timer fires, you can pick up where you left off for a specified time interval.
0
 
zealsoftCommented:
Use following function.

BOOL DoEvents()
{
        MSG msg;
       
        while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
                if(msg.message==WM_QUIT)
                        return FALSE;
                TranslateMessage(&msg);
                DispatchMessage(&msg);
        }
        return TRUE;
}
0
 
masvmasvAuthor Commented:
Thanks...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now