Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System.Diagnostics;
using System.Runtime.InteropServices;
using ppt = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;


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

        ppt.Presentation presentation;
        Microsoft.Office.Interop.PowerPoint.SlideShowView oSlideShowView;
        bool flag = false;
 
        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);
             
                ppt.SlideShowSettings sst1 = presentation.SlideShowSettings;

                sst1.LoopUntilStopped = Microsoft.Office.Core.MsoTriState.msoCTrue;

                ppt.Slides objSlides = presentation.Slides;

                sst1.LoopUntilStopped = MsoTriState.msoTrue;

                sst1.StartingSlide = 1;

                sst1.EndingSlide = objSlides.Count;

                panel1.Dock = DockStyle.Fill;
              
                sst1.ShowType = ppt.PpSlideShowType.ppShowTypeKiosk;

                ppt.SlideShowWindow sw = sst1.Run();

                oSlideShowView = presentation.SlideShowWindow.View;

                IntPtr pptptr = (IntPtr)sw.HWND;

                SetParent(pptptr, panel1.Handle);


            }
            catch (Exception)
            {

                throw;
            }


        }
        private void Form3_Load(object sender, EventArgs e)
        {
            string FileName = "D:\\test.pptx";
            open(FileName);
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            oSlideShowView.Next();
        }


Here I m Trying to Play Power Point in a Window Panel.
its playing power point file in Panel but problem is that first it play full screen within fraction of seconds it continue playing in Panel.
but i need to play directly on panel.
Please Help if any one knows.
Posted
Updated 13-Nov-17 18:18pm
v3
Comments
romanpetrov 26-Mar-13 6:14am    
I have exactly the same problem...
romanpetrov 27-Mar-13 4:25am    
Doing some research, I found that this problem not appears in PowerPoint 2013, only in previous versions of PowerPoint.
Rakesh Bairi 28-Mar-13 1:39am    
In my case I am developing Windows application installed on Client Side,Code should be Independent of Microsoft office,
romanpetrov 28-Mar-13 8:51am    
Actually, your code DEPENDS on PowerPoint version. In PowerPoint 2010, after your call ppt.SlideShowWindow sw = sst1.Run(); PowerPoint always shows slide at fullscreen. You can check this with presentation having a transition on its first slide. In PowerPoint 2013 this problem not occurs.
Rakesh Bairi 30-Mar-13 9:32am    
Thanks for answer I have one doubt should i have to use power point 2013 assembly in my code ?because in my Development machine i have office 2010

1 solution

enabled the timer tick event true
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900