
MFC中展示PPT
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
本教程介绍如何在Microsoft Foundation Classes (MFC)程序中集成和展示PowerPoint演示文稿(PPT),包括必要的API使用及示例代码。
在MFC环境下显示PPT可以通过以下步骤实现:
启动 PowerPoint:
```cpp
void CMainFrame::OnPowerpointStartpowerpoint()
{
// 检查是否已建立与PowerPoint的IDispatch连接,如果没有则创建一个。
if (m_ppt.m_lpDispatch == NULL) {
m_ppt.CreateDispatch(PowerPoint.Application);
}
// 将PowerPoint应用程序带到前台显示。
m_ppt.Activate();
}
```
开始幻灯片放映:
```cpp
void CMainFrame::OnPowerpointStartslideshow()
{
_Presentation oPresentation;
SlideShowSettings oShow;
// 连接到当前活动的演示文稿。
oPresentation.AttachDispatch(m_ppt.GetActivePresentation());
// 连接到幻灯片放映设置。
oShow.AttachDispatch(oPresentation.GetSlideShowSettings());
// 开始播放幻灯片。
oShow.Run();
}
```
创建新的幻灯片:
```cpp
void CMainFrame::OnPowerpointCreateslide()
{
_Presentation ActivePresentation(m_ppt.GetActivePresentation());
Slides oSlides(ActivePresentation.GetSlides());
const int ppLayoutTitleOnly = 11; // 幻灯片布局常量。
// 在演示文稿中添加新的幻灯片。
oSlides.Add(oSlides.GetCount() + 1, (long)ppLayoutTitleOnly);
}
```
创建新演示文稿:
```cpp
void CMainFrame::OnPowerpointCreatepresentation()
{
Presentations PresCollection;
if(m_ppt.m_lpDispatch == NULL)
MessageBox(PowerPoint is not running., Start PowerPoint);
else {
m_ppt.Activate();
PresCollection.AttachDispatch(m_ppt.GetPresentations());
// 创建一个新的演示文稿。
PresCollection.Add(1);
}
}
```
全部评论 (0)


