主頁 > 軟體工程 > VC 如何獲取PPT一幀影片結束事件

VC 如何獲取PPT一幀影片結束事件

2020-09-23 05:55:16 軟體工程

如何獲取PPT一幀影片結束事件

uj5u.com熱心網友回復:

樓主做出來了沒有?我現在也需要這個功能,求樓主共享一下

uj5u.com熱心網友回復:

使用 Application 物件的事件
請參閱 特性 
若要為 Application 物件的事件創建事件句柄,需要完成以下三個步驟: 

在類模塊中宣告一個物件變數以回應事件。 
撰寫特定的事件程序。 
在另一模塊中初始化宣告的物件。 
宣告物件變數
在為 Application 物件的事件撰寫程序之前,必須新建一個類模塊,然后宣告一個具有事件的 Application 型別的物件。例如,假設已新建一個類模塊且其名稱為 EventClassModule。該新類模塊包含以下代碼。

Public WithEvents App As Application
撰寫事件程序
宣告具有事件的新物件之后,該物件就會出現在類模塊的“物件”串列中,然后就可以為此新物件撰寫事件程序。(當在“物件”串列中選擇新物件時,“程序”串列中就會列出該物件的有效事件。)從“程序”串列中選擇一個事件;就會在類模塊中添加一個空程序。

Private Sub App_NewPresentation()

End Sub
初始化宣告的變數
在程序運行之前,必須將類模塊中宣告的物件(本示例中為 App)與 Application 物件相連。用戶可以在任意模塊中使用以下代碼實作此處理程序。

Dim X As New EventClassModule
Sub InitializeApp()
    Set X.App = Application
End Sub
運行 InitializeApp 程序。當運行此程序后,類模塊中的 App 物件就會指向 Microsoft PowerPoint 的 Application 物件,然后當事件發生時,類模塊中的事件程序就會運行。
全部顯示

SlideShowEnd 事件
請參閱 應用于 示例 特性 
本事件幻燈片放映結束后——即最后一個 SlideShowNextSlide 事件后發生。

Private Sub application_SlideShowEnd(ByVal Pres As Presentation)

application   Application 型別的物件,在類模塊中宣告,自身具有事件。有關使用 Application 物件的事件的詳細資訊,請參閱使用 Application 物件的事件。

Pres   當發生此事件時關閉演示文稿。

說明
如果 SlideShowBegin 事件已發生,則 SlideShowEnd 事件總發生在幻燈片放映結束之前。用戶可使用 SlideShowEnd 事件將 SlideShowBegin 事件中發生的任何屬性設定和變數初始值恢復到最初的設定。

示例
本示例在幻燈片放映結束時關閉從第一張到第四張幻燈片的條目效果和自動定時換片幻燈片放映切換效果。本示例也將幻燈片設定為手動換片。

Private Sub App_SlideShowEnd(ByVal Pres As Presentation)
    With Pres.Slides.Range(Array(1, 4)) _
            .SlideShowTransition
        .EntryEffect = ppEffectNone
        .AdvanceOnTime = msoFalse
    End With

    With Pres.SlideShowSettings
        .AdvanceMode = ppSlideShowManualAdvance
    End With
End Sub

uj5u.com熱心網友回復:

全部顯示

SlideShowNextSlide 事件
請參閱 應用于 示例 特性 
切換到下一張幻燈片立刻發生此事件。對于第一張幻燈片,此事件緊跟在 SlideShowBegin 事件之后發生。

Private Sub application_SlideShowNextSlide(ByVal Wn As SlideShowWindow)

application   Application 型別的物件,在類模塊中宣告,自身具有事件。有關使用 Application 物件的事件的詳細資訊,請參閱使用 Application 物件的事件。

Wn   活動幻燈片放映視窗。

示例
本示例確定了發生 SlideShowNextSlide 事件后幻燈片的位置。如果下一張幻燈片是第三張幻燈片,則本示例將滑鼠指標的型別更改為筆形且顏色更改為紅色。

Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)

   Dim Showpos As Integer

   Showpos = Wn.View.CurrentShowPosition + 1
      If Showpos = 3 Then  
         With ActivePresentation.SlideShowSettings.Run.View
            .PointerColor.RGB = RGB(255, 0, 0)
            .PointerType = ppSlideShowPointerPen
         End With
      Else
         With ActivePresentation.SlideShowSettings.Run.View
            .PointerColor.RGB = RGB(0, 0, 0)
            .PointerType = ppSlideShowPointerArrow
         End With
      End If
End Sub
本示例將全域計數器變數的值設定為 0。然后計算此事件后幻燈片上的形狀個數,確定哪些形狀具有影片,并用每個形狀的影片順序和編號填充全域陣列。

注意   本示例中創建的陣列還用于 SlideShowNextBuild 事件示例中。

Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)

   Dim i as Integer, j as Integer, numShapes As Integer
   Dim objSld As Slide

   Set objSld = ActivePresentation.Slides _
        (ActivePresentation.SlideShowWindow.View _
        .CurrentShowPosition + 1)
      With objSld.Shapes
         numShapes = .Count
         If numShapes > 0 Then
            j = 1
            ReDim shpAnimArray(1 To 2, 1 To numShapes)
            For i = 1 To numShapes
               If .Item(i).AnimationSettings.Animate Then
                  shpAnimArray(1, j) = _
                     .Item(i).AnimationSettings.AnimationOrder
                     shpAnimArray(2, j) = i
                     j = j + 1
               End If
            Next
         End If
      End With
End Sub

uj5u.com熱心網友回復:

HOW TO: Handle PowerPoint Events by Using Visual C++ .NET and MFC
Knowledge Base  

 HOW TO: Handle PowerPoint Events by Using Visual C++ .NET and MFC

 PSS ID Number: Q309309

 Article Last Modified on 09-25-2002


 --------------------------------------------------------------------------------
 The information in this article applies to: 

 Microsoft Visual C++ .NET (2002) 
 Microsoft PowerPoint 2000 
 Microsoft PowerPoint 2002

 --------------------------------------------------------------------------------
 For a Microsoft Visual C# .NET version of this article, see Q308825 . 
 For a Microsoft Visual Basic .NET version of this article, see Q308330 . 


 IN THIS TASK
 SUMMARY 
 PowerPoint Events 
 Create a C++ Application to Handle PowerPoint Events 
 Test the Application 
 REFERENCES 


 Summary
 This step-by-step article describes how to automate PowerPoint and handle events by using Visual C++ .NET.

 back to the top 

 PowerPoint Events
 PowerPoint fires events in response to user actions or in response to some methods that are called through Automation. The Application object in the PowerPoint object model fires these events on its outgoing interface, EApplication.

 To view this interface and its methods, you can use the OLE/COM Object Viewer, as follows: 
 On the Tools menu in Visual Studio .NET, select OLE/COM Object Viewer. 


 Expand the node for Type Libraries and select Microsoft PowerPoint Object Library in the list. 


 On the Object menu, select View to open the library in the ITypeLib Viewer. 


 Expand the node for coclass Application and select EApplication. 


 Note that EApplication is derived from IDispatch and is not the dispinterface that is commonly used as a source interface. If the source interface is a dispinterface, you can determine the dispatch identifiers (DISPIDs) for its methods by using the OLE/COM Object Viewer. However, because EApplication is not a dispinterface, you cannot determine the DISPIDs for PowerPoint events by examining the type library. 

 The following table lists DISPIDs for the events that the PowerPoint 2000 and PowerPoint 2002 object models expose:

 DISPID Method Name PowerPoint 2002 Only 
 2001 WindowSelectionChange   
 2002 WindowBeforeRightClick   
 2003 WindowBeforeDoubleClick   
 2004 PresentationClose   
 2005 PresentationSave   
 2006 PresentationOpen   
 2007 NewPresentation   
 2008 PresentationNewSlide   
 2009 WindowActivate   
 2010 WindowDeactivate   
 2011 SlideShowBegin   
 2012 SlideShowNextBuild   
 2013 SlideShowNextSlide   
 2014 SlideShowEnd   
 2015 PresentationPrint   
 2016 SlideSelectionChanged x 
 2017 ColorSchemeChanged x 
 2018 PresentationBeforeSave x 
 2019 SlideShowNextClick x 

uj5u.com熱心網友回復:

You can sink a PowerPoint event in your C++ application by calling IConnectionPointContainer::FindConnectionPoint to find the connection point for the desired event interface, and then IConnectionPoint::Advise with the IUnknown interface of your implementation for that event.

 back to the top 
 Create a C++ Application to Handle PowerPoint Events
 Create a new dialog box-based application by using the Microsoft Foundation Classes (MFC) Application Wizard in Visual C++ .NET. Name your project PPTEventsDemo, and then accept the default settings. The dialog box is created by default, along with the corresponding Ppteventsdemodlg.cpp and Ppteventsdemodlg.h files. 


 Add three buttons to your dialog box, and then name the buttons Launch PowerPoint, Establish Connection Point and Register Sink, and UnRegister Sink and Do Clean Up, respectively. Add a list box to the dialog box. The list box displays the names of the events as they occur. 


 In the Project explorer window in Class View, right-click PPTEventsDemo, point to Add, and then click Add Class. In the Add Class dialog box, select MFC class from TypeLibrary and then click Open. This starts the Add Class from TypeLib wizard. 


 Select Microsoft PowerPoint 10.0 object library (for PowerPoint 2002) or Microsoft PowerPoint 9.0 object library (for PowerPoint 2000) from the Available TypeLibraries drop-down list. The Interfaces list box displays all of the interfaces that the type library exposes. Select _Application and then click the > button. Accept the defaults and then click Finish. This generates the CApplication wrapper class, which is derived from COleDispatchDriver. The implementation and definition of this class is available in the Capplication.h file. 


 In Visual Studio .NET, click Resource View on the View menu to show the PPTEventsDemo dialog box. Double-click Launch PowerPoint to show the Code View window for Ppteventsdemodlg.cpp, where an empty event handler has been inserted for the Click event of that button. Add the following code to the handler for the Launch PowerPoint button: 


   if(!pptapp.CreateDispatch("Powerpoint.Application"))
   {
          AfxMessageBox("Could not create Powerpoint object.");
          return;
   }

   pptapp.put_Visible((long) 1);

uj5u.com熱心網友回復:

Add the following code to the handler for the Establish Connection Point and Register Sink button: 


 ///*********************** Start of code to get connection point **************
       //  Declare the events that you want to catch.
       // 
       //  Look for the coclass for Application in the Msppt9.olb typelib,
       //  then look for the word "source." The EApplication interface
       //  is the next search target. When you find it, you will see the 
       //  following GUID for the event interface.
       //  914934C2-5A91-11CF-8700-00AA0060263B
      static const GUID IID_IEApplication =
      {0x914934C2,0x5A91,0x11CF, {0x87,0x00,0x00,0xAA,0x00,0x60,0x26,0x3b}};

       //  Steps for setting up events.
       // 1. Get the IConnectionPointContainer interface of the server.
       // 2. Call IConnectionPointContainer::FindConnectionPoint()
       //    to find the event that you want to catch.
       // 3. Call IConnectionPoint::Advise() with the IUnknown
       //    interface of your implementation of the events.

       HRESULT hr;

       // Get the (PPT) IConnectionPointContainer interface of the server.
       IConnectionPointContainer *pConnPtContainer;
       hr = pptapp.m_lpDispatch->QueryInterface(
          IID_IConnectionPointContainer,
          (void **)&pConnPtContainer
       );
       if(FAILED(hr)) AfxMessageBox("Couldn't get IConnectionPointContainer interface.");
       ASSERT(!FAILED(hr));

       // Find a connection point for the events that you are interested in.
       hr = pConnPtContainer->FindConnectionPoint(
          IID_IEApplication,
          &m_pConnectionPoint
       );
       if(FAILED(hr)) AfxMessageBox("Couldn't find connection point via event GUID.");
       ASSERT(!FAILED(hr));

       //Instantiate the sink object.
       m_sink = new CMyPPTEventsHandler();

       //Update the list box when you obtain the events in the event handler.
       m_sink->m_pListBox = m_listBox;

      // Get the IUnknown interface of your event implementation.
       LPUNKNOWN pUnk = NULL;
       pUnk = m_sink->GetInterface(&IID_IUnknown);
       ASSERT(pUnk);

       // Setup advisory connection.
       hr = m_pConnectionPoint->Advise(pUnk, &m_sink->cookie);  
       ASSERT(!FAILED(hr));  

       // Release the IConnectionPointContainer interface.
       pConnPtContainer->Release();
 // *********************** End of code to get connection point ******************

 Add the following code to a handler for the UnRegister Sink and Do Clean Up button: 


 //Use the cookie to unregister the sink.
         m_pConnectionPoint->Unadvise(m_sink->cookie);
     m_pConnectionPoint->Release();
 //Detach the application object from the server.
     pptapp.DetachDispatch();


 Add the following code to the bottom of the constructor in the CPPTEventsDemoDlg class: 


     m_pConnectionPoint = NULL;
     pptapp = NULL; 
 Before you return from CPPTEventsDemoDlg::OnInitDialog, add the following line of code: 


       //Get the MFC class pointer for the list box on the dialog box.
       m_listBox = (CListBox*) GetDlgItem(IDC_LIST1); 
 Be sure that you place the following #include statements at the beginning of the Ppteventsdemodlg.cpp file: 


 #include "stdafx.h"
 #include "CApplication.h"
 #include "MyPPTEventsHandler.h"
 #include "PPTEventsDemo.h"
 #include "PPTEventsDemoDlg.h" 
 Forward declare the following classes in the Ppteventsdemodlg.h file: 


 class CMyPPTEventsHandler;
 class CApplication; 
 Add the following declarations as private members to CPPTEventsDemoDlg: 


         IConnectionPoint* m_pConnectionPoint;
     CApplication pptapp;
     CMyPPTEventsHandler* m_sink;
     CListBox* m_listBox;  
 In Class View in Project Explorer, right-click PPTEventsDemo, point to Add, and then click Add Class. In the AddClass dialog box, select MFC class under Templates, and then click Open. Type CMyPPTEventsHandler for the class name, select CCmdTarget for the base class, and then select Automation. For other fields, accept the defaults. Click Finish. 

 This creates a new CMyPPTEventsHandler MFC class that is derived from CCmdTarget. This class is defined in the Myppteventshandler.h file and is implemented in Myppteventshandler.cpp. This is the Event Handler class that contains methods that are called in response to the PowerPoint events. 

uj5u.com熱心網友回復:

頂頂頂 技術高

uj5u.com熱心網友回復:

In the Myppteventshandler.h file, forward declare the following class: 


 class CPresentation; 
 In the Myppteventshandler.h file, add the following members to the public declarations in the CMyPPTEventsHandler class: 


 DWORD cookie;   
 CListBox* m_pListBox;  
 Add the following methods to the protected declarations in the CMyPPTEventsHandler class: 


         void WindowSelectionChange(LPDISPATCH Pres);
     void WindowBeforeRightClick(LPDISPATCH Pres, VARIANT_BOOL* Cancel);
     void WindowBeforeDoubleClick(LPDISPATCH Pres, VARIANT_BOOL* Cancel);
     void PresentationClose ( LPDISPATCH Pres);
     void PresentationSave( LPDISPATCH Pres);
     void PresentationOpen( LPDISPATCH Pres);
     void NewPresentation( LPDISPATCH Pres);
     void PresentationNewSlide( LPDISPATCH Pres);
     void WindowActivate( LPDISPATCH Pres,LPDISPATCH Wn);
     void WindowDeactivate(LPDISPATCH Pres, LPDISPATCH Wn);
     void SlideShowBegin(LPDISPATCH Wn);
     void SlideShowNextBuild( LPDISPATCH Wn);
     void SlideShowNextSlide( LPDISPATCH Wn);
     void SlideShowEnd( LPDISPATCH Pres);
     void PresentationPrint(LPDISPATCH Pres);
     void SlideSelectionChanged(LPDISPATCH SldRange);
     void ColorSchemeChanged(LPDISPATCH SldRange);
     void PresentationBeforeSave(LPDISPATCH Pres, VARIANT_BOOL * Cancel);
     void SlideShowNextClick(LPDISPATCH Wn, LPDISPATCH nEffect);
     void PresentationPrint(LPDISPATCH Pres);

 These are the PowerPoint event handlers. 

 NOTE: The following 4 event handlers are not available in PowerPoint 2000, and are not called if the client has PowerPoint 2000: 

     void SlideSelectionChanged(LPDISPATCH SldRange);
     void ColorSchemeChanged(LPDISPATCH SldRange);
     void PresentationBeforeSave(LPDISPATCH Pres, VARIANT_BOOL * Cancel);
     void SlideShowNextClick(LPDISPATCH Wn, LPDISPATCH nEffect); 
 Replace the entire contents of Myppteventshandler.cpp with the following: 


 // MyPPTEventsHandler.cpp : implementation file.
 // 

 #include "stdafx.h"
 #include "PPTEventsDemo.h"
 #include "MyPPTEventsHandler.h"


 // CMyPPTEventsHandler.

 IMPLEMENT_DYNAMIC(CMyPPTEventsHandler, CCmdTarget)
 CMyPPTEventsHandler::CMyPPTEventsHandler()
 {
     EnableAutomation();
 }

 CMyPPTEventsHandler::~CMyPPTEventsHandler()
 {
 }


 void CMyPPTEventsHandler::OnFinalRelease()
 {
     // When the last reference for an Automation object is released,
     // OnFinalRelease is called. The base class automatically
     // deletes the object. Add additional cleanup required for your
     // object before you call the base class.

     CCmdTarget::OnFinalRelease();
 }


 BEGIN_MESSAGE_MAP(CMyPPTEventsHandler, CCmdTarget)
 END_MESSAGE_MAP()


 BEGIN_DISPATCH_MAP(CMyPPTEventsHandler, CCmdTarget)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"WindowSelectionChange",2001,WindowSelectionChange,VT_EMPTY, VTS_DISPATCH)
     DISP_FUNCTION_ID(CMyPPTEventsHandler , "WindowBeforeRightClick", 2002 ,WindowBeforeRightClick, VT_EMPTY , VTS_DISPATCH VTS_BOOL)
     DISP_FUNCTION_ID(CMyPPTEventsHandler , "WindowBeforeDoubleClick", 2003 ,WindowBeforeDoubleClick, VT_EMPTY, VTS_DISPATCH VTS_BOOL)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"PresentationClose",2004,PresentationClose,VT_EMPTY, VTS_DISPATCH)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"PresentationSave",2005,PresentationSave,VT_EMPTY, VTS_DISPATCH)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"PresentationOpen",2006,PresentationOpen,VT_EMPTY, VTS_DISPATCH)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"NewPresentation",2007,NewPresentation,VT_EMPTY, VTS_DISPATCH)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"PresentationNewSlide",2008,PresentationNewSlide,VT_EMPTY, VTS_DISPATCH)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"WindowActivate",2009,WindowActivate,VT_EMPTY, VTS_DISPATCH VTS_DISPATCH)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"WindowDeactivate",2010,WindowDeactivate,VT_EMPTY, VTS_DISPATCH VTS_DISPATCH)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"SlideShowBegin",2011,SlideShowBegin,VT_EMPTY, VTS_DISPATCH )
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"SlideShowNextBuild",2012,SlideShowNextBuild,VT_EMPTY, VTS_DISPATCH )
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"SlideShowNextSlide",2013,SlideShowNextSlide,VT_EMPTY, VTS_DISPATCH )
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"SlideShowEnd",2014,SlideShowEnd,VT_EMPTY, VTS_DISPATCH )
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"PresentationPrint",2015,PresentationPrint,VT_EMPTY, VTS_DISPATCH )
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"SlideSelectionChanged",2016,SlideSelectionChanged,VT_EMPTY, VTS_DISPATCH )
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"ColorSchemeChanged",2017,ColorSchemeChanged,VT_EMPTY, VTS_DISPATCH )
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"PresentationBeforeSave",2018,PresentationBeforeSave,VT_EMPTY, VTS_DISPATCH VTS_BOOL)
     DISP_FUNCTION_ID(CMyPPTEventsHandler,"SlideShowNextClick",2019,SlideShowNextClick,VT_EMPTY, VTS_DISPATCH VTS_DISPATCH )
     
 END_DISPATCH_MAP()

 //The GUUID is different from the one originally generated by Class Wizard. This GUUID is the same as the one for the EApplication outgoing event interface.
 static const IID IID_IMyPPTEventsHandler =
 {0x914934C2,0x5A91,0x11CF, {0x87,0x00,0x00,0xAA,0x00,0x60,0x26,0x3b}};


 BEGIN_INTERFACE_MAP(CMyPPTEventsHandler, CCmdTarget)
     INTERFACE_PART(CMyPPTEventsHandler, IID_IMyPPTEventsHandler, Dispatch)
 END_INTERFACE_MAP()


 // CMyPPTEventsHandler message handlers.

 void CMyPPTEventsHandler::WindowSelectionChange(LPDISPATCH Pres)
 {
     m_pListBox->AddString("WindowSelectionChange");
     return ; 
 }
 void CMyPPTEventsHandler::WindowBeforeRightClick(LPDISPATCH Pres, VARIANT_BOOL* Cancel)
 {
     m_pListBox->AddString("WindowBeforeRightClick");
     return ;
 }

 void CMyPPTEventsHandler::WindowBeforeDoubleClick(LPDISPATCH Pres, VARIANT_BOOL* Cancel)
 {
     m_pListBox->AddString("WindowBeforeDoubleClick");
     return;
 }

 void CMyPPTEventsHandler::PresentationClose ( LPDISPATCH Pres)
 {
     m_pListBox->AddString("PresentationClose");
     return ;
 }

 void CMyPPTEventsHandler::PresentationSave( LPDISPATCH Pres)
 {
     m_pListBox->AddString("PresentationSave");
     return ;
 }



 void CMyPPTEventsHandler::PresentationOpen( LPDISPATCH Pres)
 {
     m_pListBox->AddString("PresentationOpen");
     return ;
 }
 void CMyPPTEventsHandler::NewPresentation( LPDISPATCH Pres)
 {
     m_pListBox->AddString("NewPresentation");
     return ;
 }

 void CMyPPTEventsHandler::PresentationNewSlide( LPDISPATCH Pres)
 {
     m_pListBox->AddString("PresentationNewSlide");
     return ;
 }


 void CMyPPTEventsHandler::WindowActivate( LPDISPATCH Pres,LPDISPATCH Wn)
 {
     m_pListBox->AddString("WindowActivate");
     return ;
 }


 void CMyPPTEventsHandler::WindowDeactivate(LPDISPATCH Pres, LPDISPATCH Wn)
 {
     m_pListBox->AddString("WindowDeactivate");
     return ;
 }


 void  CMyPPTEventsHandler::SlideShowBegin(LPDISPATCH Wn)
 {
     m_pListBox->AddString("SlideShowBegin");
     return;
 }


 void  CMyPPTEventsHandler::SlideShowNextBuild( LPDISPATCH Wn)
 {
     m_pListBox->AddString("SlideShowNextBuild");
     return ;

 }


 void CMyPPTEventsHandler::SlideShowNextSlide( LPDISPATCH Wn)
 {
     m_pListBox->AddString("SlideShowNextSlide");
     return ;
 }

 void CMyPPTEventsHandler::SlideShowEnd( LPDISPATCH Pres)
 {
     m_pListBox->AddString("SlideShowEnd");
     return;
 }

 void CMyPPTEventsHandler::PresentationPrint(LPDISPATCH Pres)
 {
     m_pListBox->AddString("PresentationPrint");
     return;
 }

 //The following events are not available for PowerPoint 2000.
 void CMyPPTEventsHandler::SlideSelectionChanged(LPDISPATCH SldRange)
 {
     m_pListBox->AddString("SlideSelectionChanged");
     return ;
 }

 void CMyPPTEventsHandler::ColorSchemeChanged(LPDISPATCH SldRange)
 {
     m_pListBox->AddString("ColorSchemeChanged");
     return ;
 }

 void CMyPPTEventsHandler::PresentationBeforeSave(LPDISPATCH Pres, VARIANT_BOOL * Cancel)
 {
     m_pListBox->AddString("PresentationBeforeSave");
     return;
 }

 void CMyPPTEventsHandler::SlideShowNextClick(LPDISPATCH Wn, LPDISPATCH nEffect)
 {
     m_pListBox->AddString("SlideShowNextClick");
     return ;
 }

uj5u.com熱心網友回復:

Note that the value of the IID_IMyPPTEventsHandler static constant is changed from the value that the Class Wizard originally generated. The value is changed to the following: 
 static const IID IID_IMyPPTEventsHandler =
 {0x914934C2,0x5A91,0x11CF, {0x87,0x00,0x00,0xAA,0x00,0x60,0x26,0x3b}}; 
 This is the GUID for the EApplication outgoing event interface for the PowerPoint Application class. Also, note that the dispatch map for this class maps the DISPIDs of the events to the event handler methods.


 In the Ppteventsdemo.cpp file, add the following #include statement 


 #include "CApplication.h" 
 before the following: 
 #include "PPTEventsDemoDlg.h"  
 Add the following lines of code at the top of the InitInstance method of the Ppteventsdemoapp.cpp file: 


 if(!AfxOleInit())
     {
         AfxMessageBox("Unable to initialize COM");
         return FALSE;
     } 
 back to the top 
 Test the Application
 Press F5 to build and run the program. The dialog box appears. 


 Click Launch PowerPoint. PowerPoint starts and becomes visible. 


 Click Establish Connection Point and Register Sink to set up the event sinks. 


 Create a new presentation in PowerPoint. The WindowActivate, NewPresentation, PresentationNewSlide, SlideSelectionChange, and WindowSelectionChange events fire. 


 Start the slide show and play it through the end. The SlideShowBegin, SlideShowNextSlide, and SlideShowEnd events fire. 


 Save the presentation. The PresentationBeforeSave and PresentationSave events fire. 


 Close the presentation. The PresentationClose event fires, and the events that were triggered by PowerPoint 2002 and handled by the program appear in the list box.

 NOTE: These are the events that PowerPoint 2002 fires. You may not see some of these events in PowerPoint 2000.



 Click UnRegister Sink and Do Clean Up to disconnect the event sinks. 


 Close the dialog box. 


 back to the top 



 References
 For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base: 

 Q254009 INFO: PowerPoint 2000 Event Demonstration Available for Download 
 Q308336 HOWTO: Use Automation to Create and Show a PowerPoint Presentation with Visual C++ .NET and MFC 
 For more information on Office Automation, see the following Microsoft Office Development support site: 
 Office Development Support Center
 http://support.microsoft.com/support/officedev
 back to the top 

 Additional query words: Power Point NET events C++ MFC connection powerpoint 

 Keywords: kbAutomation _IK11561 kbGrpDSO kbHOWTOmaster 
 Issue Type: kbhowto 
 Technology: kbVCsearch kbAudDeveloper kbPowerPtSearch kbPowerPt2000 kbPowerPt2002 kbZNotKeyword2 kbPowerPt2000Search kbPowerPt2002Search kbVCNET 

uj5u.com熱心網友回復:

MSDN上的東西太爛了,只有VB的,要用VC獲取office的事件,只能使用上面的方式,VB的例子完全不能用。

uj5u.com熱心網友回復:

很有用,學習了

uj5u.com熱心網友回復:



IID號和事件的CLSID號可以用VC帶的ole/com object viewer察看。

uj5u.com熱心網友回復:

其實說白了就是要自己定義一個事件處理類,然后掛接到事件連接點上,事件連接點上需要監聽EApplication類的CLSID(uuid(914934C2-5A91-11CF-8700-00AA0060263B),)對應的事件。就這么簡單。

uj5u.com熱心網友回復:

https://support.microsoft.com/zh-cn/kb/309294
或者參考這個看看,這是針對WORD的,其實都差不多。

uj5u.com熱心網友回復:

@liuquancai1,非常感謝你的回答,解決了小弟的問題,我找PPT的guid一直沒找到正確的,最后直接使用你代碼中的,居然就找到連接點了,非常感謝。牛b

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/109600.html

標籤:ATL/ActiveX/COM

上一篇:怎樣用串口除錯助手接收大量資料并保存在同一txt檔案中?

下一篇:江湖告急,VS2005 MFC程式在Win7 32bit系統上運行,軟體選單一點,程式就無回應

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • Git本地庫既關聯GitHub又關聯Gitee

    創建代碼倉庫 使用gitee舉例(github和gitee差不多) 1.在gitee右上角點擊+,選擇新建倉庫 ? 2.選擇填寫倉庫資訊,然后進行創建 ? 3.服務端已經準備好了,本地開始作準備 (1)Git 全域設定 git config --global user.name "成鈺" git c ......

    uj5u.com 2020-09-10 05:04:14 more
  • CODING DevOps 代碼質量實戰系列第二課,相約周三

    隨著 ToB(企業服務)的興起和 ToC(消費互聯網)產品進入成熟期,線上故障帶來的損失越來越大,代碼質量越來越重要,而「質量內建」正是 DevOps 核心理念之一。**《DevOps 代碼質量實戰(PHP 版)》**為 CODING DevOps 代碼質量實戰系列的第二課,同時也是本系列的 PHP ......

    uj5u.com 2020-09-10 05:07:43 more
  • 推薦Scrum書籍

    推薦Scrum書籍 直接上干貨,推薦書籍清單如下(推薦有順序的哦) Scrum指南 Scrum精髓 Scrum敏捷軟體開發 Scrum捷徑 硝煙中的Scrum和XP : 我們如何實施Scrum 敏捷軟體開發:Scrum實戰指南 Scrum要素 大規模Scrum:大規模敏捷組織的設計 用戶故事地圖 用 ......

    uj5u.com 2020-09-10 05:07:45 more
  • CODING DevOps 代碼質量實戰系列最后一課,周四發車

    隨著 ToB(企業服務)的興起和 ToC(消費互聯網)產品進入成熟期,線上故障帶來的損失越來越大,代碼質量越來越重要,而「質量內建」正是 DevOps 核心理念之一。 **《DevOps 代碼質量實戰(Java 版)》**為 CODING DevOps 代碼質量實戰系列的最后一課,同時也是本系列的 ......

    uj5u.com 2020-09-10 05:07:52 more
  • 敏捷軟體工程實踐書籍

    Scrum轉型想要做好,第一步先了解并真正落實Scrum,那么我推薦的Scrum書籍是要看懂并實踐的。第二步是團隊的工程實踐要做扎實。 下面推薦工程實踐書單: 重構:改善既有代碼的設計 決議極限編程 : 擁抱變化 代碼整潔代碼 程式員的職業素養 修改代碼的藝術 撰寫可讀代碼的藝術 測驗驅動開發 : ......

    uj5u.com 2020-09-10 05:07:55 more
  • Jenkins+svn+nginx實作windows環境自動部署vue前端專案

    前面文章介紹了Jenkins+svn+tomcat實作自動化部署,現在終于有空抽時間出來寫下Jenkins+svn+nginx實作自動部署vue前端專案。 jenkins的安裝和配置已經在前面文章進行介紹,下面介紹實作vue前端專案需要進行的哪些額外的步驟。 注意:在安裝jenkins和nginx的 ......

    uj5u.com 2020-09-10 05:08:49 more
  • CODING DevOps 微服務專案實戰系列第一課,明天等你

    CODING DevOps 微服務專案實戰系列第一課**《DevOps 微服務專案實戰:DevOps 初體驗》**將由 CODING DevOps 開發工程師 王寬老師 向大家介紹 DevOps 的基本理念,并探討為什么現代開發活動需要 DevOps,同時將以 eShopOnContainers 項 ......

    uj5u.com 2020-09-10 05:09:14 more
  • CODING DevOps 微服務專案實戰系列第二課來啦!

    近年來,工程專案的結構越來越復雜,需要接入合適的持續集成流水線形式,才能滿足更多變的需求,那么如何優雅地使用 CI 能力提升生產效率呢?CODING DevOps 微服務專案實戰系列第二課 《DevOps 微服務專案實戰:CI 進階用法》 將由 CODING DevOps 全堆疊工程師 何晨哲老師 向 ......

    uj5u.com 2020-09-10 05:09:33 more
  • CODING DevOps 微服務專案實戰系列最后一課,周四開講!

    隨著軟體工程越來越復雜化,如何在 Kubernetes 集群進行灰度發布成為了生產部署的”必修課“,而如何實作安全可控、自動化的灰度發布也成為了持續部署重點關注的問題。CODING DevOps 微服務專案實戰系列最后一課:**《DevOps 微服務專案實戰:基于 Nginx-ingress 的自動 ......

    uj5u.com 2020-09-10 05:10:00 more
  • CODING 儀表盤功能正式推出,實作作業資料可視化!

    CODING 儀表盤功能現已正式推出!該功能旨在用一張張統計卡片的形式,統計并展示使用 CODING 中所產生的資料。這意味著無需額外的設定,就可以收集歸納寶貴的作業資料并予之量化分析。這些海量的資料皆會以圖表或串列的方式躍然紙上,方便團隊成員隨時查看各專案的進度、狀態和指標,云端協作迎來真正意義上 ......

    uj5u.com 2020-09-10 05:11:01 more
最新发布
  • windows系統git使用ssh方式和gitee/github進行同步

    使用git來clone專案有兩種方式:HTTPS和SSH:
    HTTPS:不管是誰,拿到url隨便clone,但是在push的時候需要驗證用戶名和密碼;
    SSH:clone的專案你必須是擁有者或者管理員,而且需要在clone前添加SSH Key。SSH 在push的時候,是不需要輸入用戶名的,如果配置... ......

    uj5u.com 2023-04-19 08:41:12 more
  • windows系統git使用ssh方式和gitee/github進行同步

    使用git來clone專案有兩種方式:HTTPS和SSH:
    HTTPS:不管是誰,拿到url隨便clone,但是在push的時候需要驗證用戶名和密碼;
    SSH:clone的專案你必須是擁有者或者管理員,而且需要在clone前添加SSH Key。SSH 在push的時候,是不需要輸入用戶名的,如果配置... ......

    uj5u.com 2023-04-19 08:35:34 more
  • 2023年農牧行業6大CRM系統、5大場景盤點

    在物聯網、大資料、云計算、人工智能、自動化技術等現代資訊技術蓬勃發展與逐步成熟的背景下,數字化正成為農牧行業供給側結構性變革與高質量發展的核心驅動因素。因此,改造和提升傳統農牧業、開拓創新現代智慧農牧業,加快推進農牧業的現代化、資訊化、數字化建設已成為農牧業發展的重要方向。 當下,企業數字化轉型已經 ......

    uj5u.com 2023-04-18 08:05:44 more
  • 2023年農牧行業6大CRM系統、5大場景盤點

    在物聯網、大資料、云計算、人工智能、自動化技術等現代資訊技術蓬勃發展與逐步成熟的背景下,數字化正成為農牧行業供給側結構性變革與高質量發展的核心驅動因素。因此,改造和提升傳統農牧業、開拓創新現代智慧農牧業,加快推進農牧業的現代化、資訊化、數字化建設已成為農牧業發展的重要方向。 當下,企業數字化轉型已經 ......

    uj5u.com 2023-04-18 08:00:18 more
  • 計算機組成原理—存盤器

    計算機組成原理—硬體結構 二、存盤器 1.概述 存盤器是計算機系統中的記憶設備,用來存放程式和資料 1.1存盤器的層次結構 快取-主存層次主要解決CPU和主存速度不匹配的問題,速度接近快取 主存-輔存層次主要解決存盤系統的容量問題,容量接近與價位接近于主存 2.主存盤器 2.1概述 主存與CPU的聯 ......

    uj5u.com 2023-04-17 08:20:31 more
  • 談一談我對協同開發的一些認識

    如今各互聯網公司普通都使用敏捷開發,采用小步快跑的形式來進行專案開發。如果是小專案或者小需求,那一個開發可能就搞定了。但對于電商等復雜的系統,其功能多,結構復雜,一個人肯定是搞不定的,所以都是很多人來共同開發維護。以我曾經待過的商城團隊為例,光是后端開發就有七十多人。 為了更好地開發這類大型系統,往 ......

    uj5u.com 2023-04-17 08:18:55 more
  • 專案管理PRINCE2核心知識點整理

    PRINCE2,即 PRoject IN Controlled Environment(受控環境中的專案)是一種結構化的專案管理方法論,由英國政府內閣商務部(OGC)推出,是英國專案管理標準。
    PRINCE2 作為一種開放的方法論,是一套結構化的專案管理流程,描述了如何以一種邏輯性的、有組織的方法,... ......

    uj5u.com 2023-04-17 08:18:51 more
  • 談一談我對協同開發的一些認識

    如今各互聯網公司普通都使用敏捷開發,采用小步快跑的形式來進行專案開發。如果是小專案或者小需求,那一個開發可能就搞定了。但對于電商等復雜的系統,其功能多,結構復雜,一個人肯定是搞不定的,所以都是很多人來共同開發維護。以我曾經待過的商城團隊為例,光是后端開發就有七十多人。 為了更好地開發這類大型系統,往 ......

    uj5u.com 2023-04-17 08:18:00 more
  • 專案管理PRINCE2核心知識點整理

    PRINCE2,即 PRoject IN Controlled Environment(受控環境中的專案)是一種結構化的專案管理方法論,由英國政府內閣商務部(OGC)推出,是英國專案管理標準。
    PRINCE2 作為一種開放的方法論,是一套結構化的專案管理流程,描述了如何以一種邏輯性的、有組織的方法,... ......

    uj5u.com 2023-04-17 08:17:55 more
  • 計算機組成原理—存盤器

    計算機組成原理—硬體結構 二、存盤器 1.概述 存盤器是計算機系統中的記憶設備,用來存放程式和資料 1.1存盤器的層次結構 快取-主存層次主要解決CPU和主存速度不匹配的問題,速度接近快取 主存-輔存層次主要解決存盤系統的容量問題,容量接近與價位接近于主存 2.主存盤器 2.1概述 主存與CPU的聯 ......

    uj5u.com 2023-04-17 08:12:06 more