MessagePump (PeekMessage) for managed code events?

B

Bruce

I worte an OCX with events. In order to allow the dialog box (or
whatever) to be updated by the event, I had to add a messagepump to the
event.

void MessagePump()
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT) {
PostQuitMessage((int)msg.wParam); // resubmit WM_QUIT
// Also need to abort your action here
break;
}
TranslateMessage(&msg); // Only needed if you allow keyboard messages
DispatchMessage(&msg);
}
}


How can I create a MessagePump in managed code?
 
B

Bruce

Bruce said:
I worte an OCX with events. In order to allow the dialog box (or
whatever) to be updated by the event, I had to add a messagepump to the
event.

void MessagePump()
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT) {
PostQuitMessage((int)msg.wParam); // resubmit WM_QUIT
// Also need to abort your action here
break;
}
TranslateMessage(&msg); // Only needed if you allow keyboard messages
DispatchMessage(&msg);
}
}


How can I create a MessagePump in managed code?

Do I use System::Windows::Forms::Application::DoEvents()? This seems
to work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top