Powerpoint COM 对象的每个实例共享同一个全屏显示窗口。我知道没有办法切换哪个演示文稿有那个窗口
解决方案是在您自己的窗口中托管 Powerpoint 显示
因此,这允许您缩放窗口并在一台显示器上显示多个演示文稿,或者将其从一台显示器移动到另一台显示器?
例如
var display1 = new FullScreenDisplay(); // A form with BorderStyle = None
display1.Show();
application1 = new PowerPoint.Application();
presentation1 = application1.Presentations.Open2007(....);
var slideShowSettings1 = presentation1.SlideShowSettings;
slideShowSettings1.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
var slideShowWindow1 = slideShowSettings1.Run();
IntPtr hwnd1 = (IntPtr)slideShowWindow1.HWND;
SetParent(hwnd1, display1.Handle);
var display2 = new FullScreenDisplay();
display2.Show();
application2 = new PowerPoint.Application();
presentation2 = application2.Presentations.Open2007(....);
var slideShowSettings2 = presentation2.SlideShowSettings;
slideShowSettings2.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
var slideShowWindow2 = slideShowSettings2.Run();
IntPtr hwnd2 = (IntPtr)slideShowWindow2.HWND;
SetParent(hwnd2, display2.Handle);
display1.BringToFront(); // to show slideshow 1
// or
display2.BringToFront(); // to show slideshow 2
// To advance a slide
presentation1.SlideShowWindow.View.Next();
// or
presentation2.SlideShowWindow.View.Next();
// To exit, note order!
presentation2.SlideShowWindow.View.Exit();
presentation1.SlideShowWindow.View.Exit();
Application.Exit();
这是一个 hack,可能无法在未来的 Powerpoint 版本中使用?
您还需要此导入
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);