J'ai une application wpf qui incorpore le fichier powepoint dans un contrôle webBrowser. J'ai réussi à implémenter cette fonctionnalité en utilisant l'exemple de code ci-dessous. Mais chaque fois que j'exécute le fichier ppt, le diaporama apparaît à l'écran pendant quelques secondes et ensuite seulement il s'intègre dans le contrôle. Est-il possible d'arrêter cela ou de l'exécuter en tant que processus d'arrière-plan?Intégration d'un diaporama PowerPoint dans un contrôleur
using System;
using System.Runtime.InteropServices;
using System.Windows;
using Microsoft.Office.Core;
using PPT = Microsoft.Office.Interop.PowerPoint;
namespace WpfApplication1
{
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
[DllImport("User32", CharSet = CharSet.Auto, ExactSpelling = true)]
internal static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndParent);
private void BtnOpenClick(object sender, RoutedEventArgs e)
{
const string pptFilePath = @"E:\Sample.ppt";
var pptApplication = new PPT.Application
{
ShowWindowsInTaskbar = MsoTriState.msoFalse
};
var presentation = pptApplication.Presentations.Open(pptFilePath, MsoTriState.msoCTrue,
MsoTriState.msoTrue, MsoTriState.msoFalse);
var slideShowWindow = presentation.SlideShowSettings.Run();
slideShowWindow.Height = (int)(0.85 * webBrowser1.Height);
slideShowWindow.Width = (int)(0.75 * webBrowser1.Width);
SetParent(new IntPtr(presentation.SlideShowWindow.HWND), webBrowser1.Handle);
}
}
}
Avez-vous trouvé une solution à votre problème? Moi aussi j'essaie d'intégrer un PowerPoint dans une application WPF. – Meirion
@Meirion désolé je n'ai pas encore eu de solution. La seule autre option consiste à enregistrer chaque diapositive sous forme d'images et à les utiliser de manière séquentielle. Mais ce n'est pas une solution décente. – pRimE