共用方式為


AfxOleGetMessageFilter

擷取應用程式的目前訊息篩選器。

COleMessageFilter* AFXAPI AfxOleGetMessageFilter( );

傳回值

變數的指標,目前的郵件篩選器。

備註

呼叫此函式來存取目前的COleMessageFilter-衍生物件,就像您會呼叫AfxGetApp用來存取目前的應用程式物件。

範例

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();
   }
   //...
   //...
   //...

需求

標頭: <afxwin.h>

請參閱

參考

COleMessageFilter 類別

AfxGetApp

概念

MFC 巨集和全域變數