【问题标题】:VB.net embedded powerpoint slideshow not proceedingVB.net 嵌入式 powerpoint 幻灯片不进行
【发布时间】:2018-11-21 03:28:56
【问题描述】:

我有一个应用程序,它在面板中嵌入了一个 powerpoint 应用程序并自动运行幻灯片。这很好用,即使是 powerpoint 上的动画。但是,当表单失去焦点时,幻灯片会停止并且不会继续,直到表单重新获得焦点。

这是一个问题,因为当我在我的 PC 上做其他事情时,演示文稿必须在后面运行。我在想它可以通过 user32.dll 中的一个函数来解决,以触发它具有焦点的表单或类似的东西。但是直到现在我还没有成功地使这项工作顺利进行。关于如何解决这个问题的任何想法?

我用来嵌入 powerpoint 的代码:

 Dim ofd As New OpenFileDialog
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then

            Dim pres As PowerPoint.Presentation
            Dim objslides As PowerPoint.Slides

            app = New PowerPoint.Application
            pres = app.Presentations.Open(ofd.FileName, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoTrue)
            ' app.WindowState = PowerPoint.PpWindowState.ppWindowMinimized
            objslides = pres.Slides

            With pres.SlideShowSettings
                .LoopUntilStopped = MsoTriState.msoTrue
                .StartingSlide = 1
                .EndingSlide = objslides.Count
                .ShowType = PowerPoint.PpSlideShowType.ppShowTypeKiosk
                .AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings
                .ShowPresenterView = MsoTriState.msoFalse
                .ShowWithAnimation = MsoTriState.msoTrue
                .ShowWithNarration = MsoTriState.msoFalse
            End With

            sw = pres.SlideShowSettings.Run()

            Dim screenClasshWnd = FindWindow("screenClass", 0)

            SetParent(screenClasshWnd, Panel1.Handle)
            SetWindowPos(sw.HWND, 1, 0, 0, Panel1.Width, Panel1.Height, 0)

            swview = sw.View

【问题讨论】:

    标签: vb.net powerpoint


    【解决方案1】:

    最后,我找到了解决方法。在对 PowerPoint 进行了一些研究后,我发现在 PowerPoint 中打开的幻灯片在应用程序失去焦点时也会“冻结”。所以,为了解决这个问题,我在一个单独的窗口中打开了幻灯片:

    With pres.SlideShowSettings
                .LoopUntilStopped = MsoTriState.msoTrue
                .StartingSlide = 1
                .EndingSlide = objslides.Count
                .ShowType = PowerPoint.PpSlideShowType.ppShowTypeWindow
                .AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings
                .ShowPresenterView = MsoTriState.msoFalse
                .ShowWithAnimation = MsoTriState.msoTrue
                .ShowWithNarration = MsoTriState.msoFalse
            End With
    

    这会在带有 Windows 7 样式边框的表单中提供幻灯片。使用 user32.dll 中的“SetWindowPosition”,可以更改此窗口的大小和位置,使蓝色边框不再可见。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      • 1970-01-01
      相关资源
      最近更新 更多