在 C# Win Form 中嵌入 PowerPoint Viewer
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1259369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Embed PowerPoint Viewer in C# Win Form
提问by Soppus
Is it possible to Embed a PowerPoint Viewer into a C# Windows Form?
是否可以将 PowerPoint 查看器嵌入到 C# Windows 窗体中?
I am currently use the following code:
我目前使用以下代码:
objApp = new PowerPoint.Application();
//objApp.Visible = MsoTriState.msoTrue;
objPresSet = objApp.Presentations;
objPres = objPresSet.Open(ppsAction.FileInfo.FullName, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
objSlides = objPres.Slides;
//Run the Slide show
objSSS = objPres.SlideShowSettings;
objSSS.ShowType = Microsoft.Office.Interop.PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
objSSS.LoopUntilStopped = MsoTriState.msoTrue;
objSSS.Run();
WindowWrapper handleWrapper = new WindowWrapper(objPres.SlideShowWindow.HWND);
SetParent(handleWrapper.Handle, this.ApplicationPanel.Handle);
this.ApplicationPanel.Visible = true;
objPres.SlideShowWindow.Height = ApplicationPanel.Height;
objPres.SlideShowWindow.Width = ApplicationPanel.Width;
objPres.SlideShowWindow.Top = 0;
objPres.SlideShowWindow.Left = 0;
It shows the viewer on the form but the placement and sizing is wrong. How would one size and place it correctly.
它在表单上显示查看器,但位置和大小错误。如何将一种尺寸正确放置。
Another option:
I have encountered the Aximp.exe application meant to be used for showing ActiveX controls on the Win Forms in C#. How would I use this with the PPT Viewer?
另一种选择:
我遇到了 Aximp.exe 应用程序,该应用程序旨在用于在 C# 中的 Win Forms 上显示 ActiveX 控件。我将如何在 PPT 查看器中使用它?
采纳答案by danish
回答by Pasan Indeewara
Thanks for good links, http://support.microsoft.com/kb/304662has useful info... That helped me :)
感谢提供良好的链接,http://support.microsoft.com/kb/304662有有用的信息......这对我有帮助:)
回答by Dodo
For placement change the objPres.SlideShowWindow.Top
to 10 as example and objPres.SlideShowWindow.Left
to 12 so the upper left corner of the slide will be at (12,10) where left move it horizontal and the top move it down vertically.
对于放置更改objPres.SlideShowWindow.Top
为 10 作为示例,并更改objPres.SlideShowWindow.Left
为 12,因此幻灯片的左上角将在 (12,10) 处,向左移动水平方向,顶部垂直向下移动。