Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
MFC
TRY
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

AfxOleGetMessageFilter

Retrieves the application's current message filter.

COleMessageFilter* AFXAPI AfxOleGetMessageFilter( );

A pointer to the current message filter.

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

COleMessageFilter* pFilter = AfxOleGetMessageFilter();
ASSERT_VALID(pFilter);
pFilter->BeginBusyState();
// do things requiring a busy state
pFilter->EndBusyState();
// Another example 
//CWinApp-derived class
BOOL CCMFCAutomationApp::InitInstance()
{
	CWinApp::InitInstance();

	// Initialize OLE libraries 
	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. 
      //CMyMessageFilter is derived from COleMessageFilter
      pThread->m_pMessageFilter = new CMyMessageFilter;
      ASSERT(AfxOleGetMessageFilter() != NULL);

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

Header: <afxwin.h>

Community Additions

ADD
Show:
© 2015 Microsoft