谁知道如何制作或下载控件以查看 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/