Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
AfxOleGetMessageFilter
TRY
Collapse the table of content
Expand the table of content

AfxOleGetMessageFilter

Retrieves the application's current message filter.

COleMessageFilter* AFXAPI AfxOleGetMessageFilter( );

Return Value

A pointer to the current message filter.

Remarks

Call this function to access the current COleMessageFilter-derived object, just as you would call AfxGetApp to access the current application object.

Example

// example of AfxOleGetMessageFilter
COleMessageFilter* pFilter = AfxOleGetMessageFilter();
ASSERT_VALID(pFilter);
pFilter->BeginBusyState();
// do things requiring a busy state
pFilter->EndBusyState();

// another example
//CWinApp-derived class
BOOL CSAProjApp::InitInstance()
{
   // Initialize OLE libraries and registers default message filter.
   if (!AfxOleInit())
   {
      AfxMessageBox("Ole initialization failed\n");
      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.
      //CMyMessageFilter is derived from COleMessageFilter
      pThread->m_pMessageFilter = new CMyMessageFilter;
      ASSERT(AfxOleGetMessageFilter() != NULL);

      // Register the new message filter object.
      AfxOleGetMessageFilter()->Register();
   }
   //...
   //...
   //...
}

Requirements

Header: <afxwin.h>

See Also

MFC Macros and Globals | COleMessageFilter | AfxGetApp

Show:
© 2015 Microsoft