MFC控制:实现打开PPT详细步骤
来源:互联网 发布:淘宝超时发货赔付规则 编辑:程序博客网 时间:2024/05/17 04:41
其余选择默认,一直“下一步”即可。
为了使用PPT功能,添加类
不知道生成哪些类,可全部生成。之后将主要用到以下几类
把以上需要用到的头文件添加到工程的头文件中,并且要把以上添加的每个头文件的import注释掉,如CApplication.h
// Machine generated IDispatch wrapper class(es) created with Add Class from Typelib Wizard// #import "D:\\Program Files\\Microsoft Office\\OFFICE11\\MSPPT.OLB" no_namespace// CApplication wrapper class
在应用程序DetectDlg.cpp的InitInstance()中初始化OLE和创建PowerPoint接口对象,代码如下:
// Initialize OLE librariesif (!AfxOleInit()){AfxMessageBox("Failed to initialize OLE");return FALSE;}//Start PowerPoint and get Application object...if (!app.CreateDispatch("Powerpoint.Application")){AfxMessageBox("Couldn't start PowerPoint.");return FALSE;}
在对话框应用程序的头文件中添加如下头文件和变量
#include "CApplication.h"#include "CPresentation.h"#include "CPresentations.h"#include "CSlideShowView.h"#include "CSlideShowWindow.h"#include "CSlideShowSettings.h"#include "CSlides.h"#include "CSlide.h" public:CApplication app;CPresentation presentation;CPresentations presentations;CSlideShowView slideShowView;CSlideShowWindow slideShowWindow;CSlideShowSettings slideShowSettings;CSlides slides;CSlide slide;
添加一个按钮,在其click函数中添加代码
// Make PowerPoint visible and display a messageapp.put_Visible(TRUE); // 有时候为了ppt不影响程序,会设置启动大小// app.put_Width(100);// app.put_Height(100); ////////////两种打开文件方法//////////////////////////////////////////////////实现1.生成选择ppt文件对话框/*CString strFilter = "PowerPoint Files (*.ppt;*.pptx)|*.ppt;*.pptx|All Files(*.*)|*.*||";CFileDialog FileDlg(TRUE, "PPT", NULL, OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON| OFN_PATHMUSTEXIST, strFilter);FileDlg.DoModal();// To get the selected file's path and nameCString strFileName;strFileName = FileDlg.GetPathName();*///实现2.直接选择需要打开的ppt文件CString strFileName("H:\\SpotDetect\\Detect\\Test.ppt");//////////////////////////////////////////////////if (!strFileName.IsEmpty()){presentations = app.get_Presentations();presentation = presentations.Open(strFileName, 0, 0, 1);//打开相应ppt文件} presentations = app.get_ActivePresentation();slides = presentation.get_Slides();// Show the first slide of the presentationslide = slides.Item(COleVariant((long)1));//运行这个演示Sleep(2000);slideShowSettings = presentation.get_SlideShowSettings();slideShowSettings.Run();//这里可以改变ppt大小/*slideShowWindow = presentation.GetSlideShowWindow();slideShowWindow.SetWidth(100);slideShowWindow.SetHeight(100);*/ //关闭PPT//presentation = app.get_ActivePresentation();//presentation.Close();
这样就可以成功打开一个ppt文件了。
之后将更新对PPT文件的操作和项目中的交互操作。
阅读全文
0 0
- MFC控制:实现打开PPT详细步骤
- MFC 打开word、ppt、pdf文件方法
- yii2搭建完美后台并实现rbac权限控制案例 - 之权限控制详细操作步骤
- js实现打开word.ppt.Excel等
- 怎么把PPT转成EXE格式,详细步骤
- PDF怎么转为PPT格式的详细步骤
- 用转换器把ppt转为pdf的详细步骤
- VS2013操作PowerPoint,在MFC窗口中打开PPT
- 关于mfc 对powerpoint的操作,控制ppt播放
- 配置Xcode版本控制SVN详细步骤
- vnc远程控制服务器详细步骤~
- 恢复控制文件故障详细步骤
- 恢复控制文件故障详细步骤
- yii2 rbac权限控制详细操作步骤
- MFC中最近打开文件控制
- Android Beam 详细实现步骤
- js实现打开word.ppt.Excel等(原理)
- js实现打开word.ppt.Excel等(原理)
- liferay7项目搭建
- leetcode 100. Same Tree
- TestNG参数化测试之Excel读取数据
- 软件工程课程设计问题总结——医院门诊系统(一):serverlet中alert不弹窗&弹窗乱码
- vscode插件离线安装方法
- MFC控制:实现打开PPT详细步骤
- 杂念
- Lombok工具
- PAT甲级 1009. Product of Polynomials (25)
- JS-Array对象
- PAT (Advanced Level) Practise 1095 Cars on Campus (30)
- activiti自动生成流程图片配置,按下图操作,然后保存时会自动生成流程图片。(设置完要重启eclipse)
- 程序员必备:linux日常维护命令
- python远程连接oracle配置和语法