DoEvents in C++

Hello,

In VisualC++ I have a program that calls DoEvents() and works just fine.  

I moved the exact same code outside VisualC++, since I need it as a stand alone program.  However, my DoEvents() now do cause linkage problems.  These look like:

void DoEvents(void)
{
    MSG msg;
    while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
    {
       TranslateMessage(&msg);
       DispatchMessage(&msg);
    }
}

DoEvents processes Windows Messages in the message queue. C++ does not have a one command counterpart. What can I do?  I need a DoEvents in plain C++!  Anyone knows?
sceciliaAsked:
Who is Participating?
 
UncleJimboConnect With a Mentor Commented:
DoEvents is just a function defined in a windows library, VC++ probably just automatically includes the library header, and link the library in when compiling/linking.

Basically when you compile (example here is for the GNU c++ compiler)

g++ yourprogram.cpp -o yourprogram.exe -lKernel32

The -lKernel32 means link to the Kernel32 library.

I think Kernel32 is the right library for DoEvents, check it and lemme know if it works.
0
 
sceciliaAuthor Commented:
Dear UncleJimbo,

Kernel32.LIB did not work but User32.LIB did.  Thanks to your comment I got a better idea about which library to include.
0
 
bcladdCommented:
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to UncleJimbo: Grade B

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0
All Courses

From novice to tech pro — start learning today.