Bonjour,

J'ai besoin d'afficher (d'une manière ou d'une autre) des diaporamas dans un composant de mon form que je peux redimensionner. Je ne veux devoir modifier le format du fichier (convertir en vidéo en html ...). J'avoue que mon niveau en C# et en Anglais me bloque alors si vous avez une solution merci d'avance de penser à moi

J'ai trouvé 2 solutions pour afficher mon powerpoint dans mon form mais ça fonctionne pas comme je veux

Solution 1
https://support.microsoft.com/fr-fr/...ts-in-visual-c

  1. à cette ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    axWebBrowser1.Navigate(strFileName, ref refmissing, ref refmissing, ref refmissing, ref refmissing);
    une boite de dialogue s'ouvre pour me demander si j'ouvre ou enregistre le fichier
  2. Le document s'ouvre mais dans powerpoint et non dans ma form


Si vous avez une solution ...

Solution 2
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Office.Interop.PowerPoint;
using ppt = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
 
namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        [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);
        Presentation presentation;
 
        SlideShowView oSlideShowView;
        int slideEnCours = 0;
        int totalSlides = 0;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            string FileName = @"C:\Users\...\Documents\Visual Studio 2015\Projects\VisualisationDynamique\Présentation1.pptx";
            open(FileName);
        }
 
        public void open(string FileName)
        {
            try
            {
                ppt.Application application;
                // For Display in Panel
                IntPtr screenClasshWnd = (IntPtr)0;
                IntPtr x = (IntPtr)0;
                application = new ppt.Application();
                presentation = application.Presentations.Open(FileName, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
                SlideShowSettings sst1 = presentation.SlideShowSettings;
                sst1.LoopUntilStopped = MsoTriState.msoFalse;
                Slides objSlides = presentation.Slides;
                sst1.LoopUntilStopped = MsoTriState.msoTrue;
                sst1.StartingSlide = 1;
                sst1.EndingSlide = objSlides.Count;
                totalSlides = objSlides.Count;
 
                sst1.ShowType = PpSlideShowType.ppShowTypeKiosk;
                SlideShowWindow sw = sst1.Run();
 
                presentation.SlideShowSettings.ShowWithAnimation = Microsoft.Office.Core.MsoTriState.msoTrue;
                presentation.SlideShowWindow.Width = panel1.Width-100;
                presentation.SlideShowWindow.Height = panel1.Height-100;
 
                oSlideShowView = presentation.SlideShowWindow.View;
                IntPtr pptptr = (IntPtr)sw.HWND;
                SetParent(pptptr, panel1.Handle);
            }
            catch (Exception)
            {
                throw;
            }
        }
 
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            oSlideShowView.Next();
            slideEnCours += 1;
            if (slideEnCours >= totalSlides)
            {
                timer1.Enabled = false;
                slideEnCours = 0;
                panel1.Visible = false;
            }
            this.Refresh();
        }
  1. Ca marche pas mal mais je n'arrive pas à charger une nouvelle présentation
  2. Le powerpoint n'utilise pas le timer prés réalisé



Si vous avez une idée


Par avance merci pour votre aide