Article ID: 152074
Article Last Modified on 11/21/2006
//
// Definition of new COleMessageFilter-derived class.
//
class CMyMessageFilter : public COleMessageFilter
{
public:
virtual BOOL OnMessagePending(const MSG* pMsg);
};
//
// Add a member variable to the CWinApp-derived class.
//
public:
CMyMessageFilter MMF;
//
// Add to the CWinApp::InitInstance after calling AfxOleInit.
//
COleMessageFilter* OldFilter = AfxOleGetMessageFilter();
OldFilter->Revoke();
MMF.Register();
//
// Definition of OnMessageFilter.
//
BOOL CMyMessageFilter::OnMessagePending(const MSG* pMsg)
{
MSG msg;
while (PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT,
PM_REMOVE | PM_NOYIELD))
{
DispatchMessage(&msg);
}
if (pMsg->message == WM_PAINT) return TRUE;
return FALSE;
}
//
// Add to CWinApp::ExitInstance.
//
MMF.Revoke();
return CWinApp::ExitInstance();
Additional query words: 2.00 2.10 2.20 4.00 4.10
Keywords: kbcode kbprb KB152074