.net - Powerpoint 查看器控件 C#/VB/.NET

标签 .net powerpoint

谁知道如何制作或下载控件以查看 powerpoint 文档?

我搜索过,但唯一出现的是 this ,这绝对不是免费的。我敢肯定,Microsoft 一定已经有一个控件可以执行此操作。

制作一个控件来做到这一点也很受欢迎。

最佳答案

这里有我一直在处理的问题的解决方案。 如果有人遇到同样的问题,我会在此处留下我经过数小时工作后做出的解决方案。

        [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);


        private string FileName = "";
        PowerPoint.Application application;
        PowerPoint.Presentation presentation;
        bool flag = false;

        public UserControl1()
        {
            InitializeComponent();
        }


        public void open()
        {
            sair();

            openFileDialog1.Filter = "Powerpoint file (*.ppt)|*.ppt|All files (*.*)|*.*";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileName = openFileDialog1.FileName;

                IntPtr screenClasshWnd = (IntPtr)0;
                IntPtr x = (IntPtr)0;

                flag = true;

                application = new PowerPoint.Application();
                presentation = application.Presentations.Open2007(FileName, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);
                PowerPoint.SlideShowSettings sst1 = presentation.SlideShowSettings;


                sst1.ShowType = (PowerPoint.PpSlideShowType)1;
                PowerPoint.SlideShowWindow sw = sst1.Run();


                sw.Height = (panel1.Height) - 64;
                sw.Width = (panel1.Width) - 130;

                IntPtr formhWnd = FindWindow(x, "Form1");
                IntPtr pptptr = (IntPtr)sw.HWND;
                screenClasshWnd = FindWindow(x, "screenClass");
                SetParent(pptptr, panel1.Handle);

                this.Focus();

                this.application.SlideShowEnd += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowEndEventHandler(SlideShowEnds);
            }
        }

关于.net - Powerpoint 查看器控件 C#/VB/.NET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9621771/

相关文章:

c# - 如何在powerpoint中添加项目符号

c# - 将 BeginTransaction 与 Dapper.IDbConnection 一起使用的正确方法

c# - 在 PowerPoint 演示文稿中包含代码示例的最佳方式是什么

c# - 如何保证异步方法继续在另一个线程上运行?

.net - MSBuild 和 F# 的 FAKE 有什么区别?

vba - 用vba创建powerpoint形状

java - Apache POI PPT (Java) - 更新 TextShape 保持文本格式/形状格式

powershell - Powerpoint的禁用和自动恢复选项

c# - Action 的通用约束没有按预期工作

c# - 声明有界类型的泛型字典