Здесь есть решение проблемы, которую я ищу.
Если у кого-то есть такая же проблема, я оставляю решение, принятое мной после многих часов работы.
[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);
}
}