共用方式為


AfxOleGetMessageFilter

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

COleMessageFilter* AFXAPI AfxOleGetMessageFilter( );

傳回值

指向目前訊息篩選器的指標。

備註

就像您會呼叫 AfxGetApp 來存取目前應用程式物件一般,請呼叫這個函式存取目前的 COleMessageFilter 衍生物件。

範例

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 巨集和全域