我有一个将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
答案 0 :(得分:0)
最后,我找到了解决方法。在对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”,可以更改此窗口的大小和位置,以使蓝色边框不再可见。