Article ID: 179692
Article Last Modified on 11/21/2006
CMyMessageFilter : public COleMessageFilter
{
virtual BOOL OnMessagePending(const MSG* pMsg);
}
BOOL CMyMessageFilter::OnMessagePending(const MSG* pMsg)
{
//The base class function dispatches WM_PAINT
//by returning FALSE no messages are being processed; the
//user can add code here to appropriately handle messages.
//WARNING: Not processing WM_PAINT messages will cause the user
// interface to appear to hang and not update until the
// current COM method call returns.
return FALSE;
}BOOL CmyApp::InitInstance()
{
// Initialize OLE libraries and registers default message filter.
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
CWinThread* pThread = AfxGetThread();
if (pThread != NULL)
{
// Destroy message filter, thereby unregistering it.
delete pThread->m_pMessageFilter;
pThread->m_pMessageFilter = NULL;
// Create the new message filter object.
pThread->m_pMessageFilter = new CMyMessageFilter;
ASSERT(AfxOleGetMessageFilter() != NULL);
// Register the new message filter object.
AfxOleGetMessageFilter()->Register();
}
...
...
} For more information on how message filters work, please see the online
documentation on IMessageFilter and COleMessageFilter.Additional query words: 80010005 2147549189 IMessageFilter MessagePending COleMessageFilter OnDraw
Keywords: kberrmsg kbtshoot kbarchitecture kbcontainer kbprb kbcode KB179692