mfc中嵌入ppt,播放的时候在对话框中播放

本人想通过VC调用PowerPoint的接口来操作PPT文档,一切都好,可就是解析的时候调用open函数,会弹出PowerPoint的窗口,再然后将窗口隐藏

 


 _Application *g_app = NULL;

     _Presentation *g_pPresentation;
     Presentations *pPresentations = NULL;
     Slides *g_pSlides;
 
     HRESULT  hr;
 
     // COM环境初始化
     hr = CoInitialize(NULL);
 
     if  (FAILED(hr))
     {
         return ;
     }
 
     // 创建Application类,返回_Application接口
     hr = CoCreateInstance(__uuidof(PowerPoint::Application),
                             NULL,
                             CLSCTX_LOCAL_SERVER,
                             __uuidof(PowerPoint::_Application),
                             ( LPVOID  *)&g_app);
 
     g_app->put_Visible(msoTrue);                    // 显示Powerpoint窗口 
                // 此处如果不让PowerPoint窗口弹出,后面的操作都没法进行
     g_app->put_WindowState(ppWindowMinimized);        // 窗口最小化
 
     g_app->get_Presentations(&pPresentations);        // 获取Presentaions类
 
     //打开PPT文件,返回_Presentation接口
     pPresentations->Open(_bstr_t(pptPath), msoFalse, msoFalse, msoTrue, &g_pPresentation);
 
     g_pPresentation->get_Slides(&g_pSlides);        // 获取Slides
 
     long  count = 0;
     g_pSlides->get_Count(&count);
 
     // 遍历每张Slide

 

g_app->put_Visible(msoTrue); // 显示Powerpoint窗口
          // 此处如果不让PowerPoint窗口弹出,后面的操作都没法进行

我不知道为什么会这样,我觉得弹出来很不爽,我见过有些PPT处理软件,也打开了PowerPoint的进程,但是没见到窗口弹出,不知道是如何实现的,望各位大侠帮忙啊!感激不尽!如果有解决方案,本人再加200分

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



 我都试过了,没问题的。

这这两句删除。
g_app->put_Visible(msoTrue); 
g_app->put_WindowState(ppWindowMinimized);

只需要Open的第四个参数设置为msoFalse。

pPresentations->Open(_bstr_t(pptPath), msoFalse, msoFalse,msoFalse, &g_pPresentation);

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
MFC 显示PPT //启动 PowerPoint: void CMainFrame::OnPowerpointStartpowerpoint() { /// Check if the IDispatch connection exists with PowerPoint, // if not create one. if (m_ppt.m_lpDispatch == NULL) { // Create IDispatch connection to PowerPoint. m_ppt.CreateDispatch("PowerPoint.Application"); }; // Bring the PowerPoint application to the front. m_ppt.Activate(); } void CMainFrame::OnPowerpointStartslideshow() { _Presentation oPresentation; SlideShowSettings oShow; // Attach to the Active Presentation. oPresentation.AttachDispatch(m_ppt.GetActivePresentation()); // Attach to the slide-show settings. oShow.AttachDispatch(oPresentation.GetSlideShowSettings()); // Run the slide show. oShow.Run(); } // 创建幻灯片: void CMainFrame::OnPowerpointCreateslide() { // Connect to the active presentation. There is no error trapping. // If the active presentation the framework traps // the error and displays a message box. _Presentation ActivePresentation(m_ppt.GetActivePresentation()); // Connect to the slides collection. Slides oSlides(ActivePresentation.GetSlides()); // This constant is defined in the PowerPoint Object model. // You can use the Object Browser, with Visual Basic Editor // (VBE), to look up the different constant values. const ppLayoutTitleOnly = 11; // Add a new slide to the presentation. This code adds the new // slide to the end of the presentation. oSlides.Add(oSlides.GetCount() + 1l, ppLayoutTitleOnly); } // 创建演示文稿: void CMainFrame::OnPowerpointCreatepresentation() { Presentations PresCollection; // Make sure there is a dispatch pointer for PowerPoint. if(m_ppt.m_lpDispatch == NULL) { // Display a message indicating that PowerPoint is not running. MessageBox("PowerPoint is not running.", "Start PowerPoint"); } else { // Bring PowerPoint to the front. m_ppt.Activate(); // Attach the presentations collection to the PresCollection // variable. PresCollection.AttachDispatch(m_ppt.GetPresentations()); // Create a new presentation. PresCollection.Add(1);

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值