PowerPoint Viewer嵌入问题

我在我的主窗体中嵌入了一个PowerPoint Viewer,以显示一个pptx文件。 我的电脑上有2台显示器,我正在尝试在第二台显示器上运行应用程序。 当我在监视器1上运行程序时,一切都按预期工作。 但是当我在监视器2上运行它(意味着我更改代码以在第二个监视器上运行应用程序,而不是运行应用程序然后将其自己移动到第二个监视器)时,PowerPoint Viewer将在第一个监视器上打开,然后移动到程序运行的第二个监视器。 我认为这与PowerPoint对象没有正确设置,但不太确定。 这是我的代码:

[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] static extern IntPtr FindWindow(IntPtr ZeroOnly, string lpWindowName); [DllImport("user32.dll", SetLastError = true)] static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern bool SetWindowText(IntPtr hwnd, String lpString); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, UIntPtr lParam); public const uint WM_SETFOCUS = 0x0007; Microsoft.Office.Interop.PowerPoint.Application application; Microsoft.Office.Interop.PowerPoint.Presentation presentation; public MainForm() { InitializeComponent(); DisplayOnMonitor(); } private void MainForm_Load(object sender, EventArgs e) { LoadSlideShow(); } private void LoadSlideShow() { IntPtr screenClasshWnd = (IntPtr)0; IntPtr x = (IntPtr)0; application = new Microsoft.Office.Interop.PowerPoint.Application(); presentation = application.Presentations.Open2007( Settings.Default.PowerPointPath, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse); Microsoft.Office.Interop.PowerPoint.SlideShowSettings sst1 = presentation.SlideShowSettings; sst1.LoopUntilStopped = Microsoft.Office.Core.MsoTriState.msoTrue; Microsoft.Office.Interop.PowerPoint.SlideShowWindow sw = sst1.Run(); IntPtr pptptr = (IntPtr)sw.HWND; SetParent(pptptr, splitContainerControl.Panel1.Handle); splitContainerLeft.Panel1.LostFocus += new EventHandler(OnLostFocus); splitContainerControl.PreviewKeyDown +=new PreviewKeyDownEventHandler(OnPreviewKeyDown); splitContainerLeft.Panel1.AutoSize = true; splitContainerControl.Panel1.Focus(); } private void DisplayOnMonitor() { Screen[] sc; sc = Screen.AllScreens; this.FormBorderStyle = FormBorderStyle.None; this.Left = sc[1].Bounds.Width; this.Top = sc[1].Bounds.Height; this.StartPosition = FormStartPosition.Manual; this.Location = sc[1].Bounds.Location; Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y); this.Location = p; this.WindowState = FormWindowState.Maximized; } 

我知道在调用sst1.Run()方法时会出现PowerPoint Viewer,但我尝试在应用之前(和之后)使应用程序不可见,但它会引发exception。 如果有办法指示sst1打开哪个显示器,那么我认为它可以解决问题,但到目前为止我没有任何运气。

任何帮助表示赞赏!