Click to See Complete Forum and Search --> : Usage of PeekMessage().....


Ramkumar Ganesan
May 11th, 1999, 04:54 PM
I'm trying to use PeekMessage() to search thro' the message queue for a dialog and I want to break-off the PeekMessage() loop on encountering a specific message (e.g , WM_CLOSE). How should I do this..??

while( PeekMessage())
{
if the message is WM_CLOSE, fall off this loop
}

//control should come here.....

Any help is greatly appreciated. Any other better ideas are welcome too.....

Thanx
Ram

May 11th, 1999, 06:54 PM
I use th following function for my dialog:

BOOL WorkingDlg::IsCancelled()
{
MSG msg;

if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{

if (msg.message == WM_QUIT ||
msg.message == WM_CLOSE ||
msg.message == WM_DESTROY
)
m_bCancel = TRUE;
TranslateMessage(&msg);// Translates virtual key codes
DispatchMessage(&msg); // Dispatches message to window
}

return m_bCancel;
}

This function will be called by other program to see if user clicks the "Cancel" button or close the dialog.
Hope this will help. Good luck.

Allen

Ramkumar Ganesan
May 12th, 1999, 08:49 AM
That helped. Thanx a lot.