速达社区

速达社区 ›› 网络编程 ›› c#如何在窗口中播放PowerPoint,而不是全屏播放?

页码: 1

c#如何在窗口中播放PowerPoint,而不是全屏播放?

- 水亦蓝 2009-03-20 02:21

网上的例子都是全屏播放而不是在窗口中播放PowerPoint.

- 烧焦面包 2009-03-20 02:21

用WebBrowser加载office

- 尹洪龙 2009-03-20 02:21

举个例子a!

- 永恒の律 2009-03-20 02:21

using   System;
using   System.Drawing;
using   System.Collections;
using   System.ComponentModel;
using   System.Windows.Forms;
using   System.Data;
using   System.Reflection;

namespace   WebBrowserOffice
{
///   <summary>
///   Form1   的摘要说明。
///   </summary>
public   class   Form1   :   System.Windows.Forms.Form
{
               private   Object   oDocument;
               private   System.Windows.Forms.Button   button1;
               private   AxSHDocVw.AxWebBrowser   axWebBrowser1;
               private   System.Windows.Forms.OpenFileDialog   openFileDialog1;  
///   <summary>
///   必需的设计器变量。
///   </summary>
private   System.ComponentModel.Container   components   =   null;

public   Form1()
{
//
//   Windows   窗体设计器支持所必需的
//
InitializeComponent();

//
//   TODO:   在   InitializeComponent   调用后添加任何构造函数代码
//
                       this.axWebBrowser1.NavigateComplete2   +=   new   AxSHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.axWebBrowser1_NavigateComplete2);
                       this.Load   +=   new   System.EventHandler(this.Form1_Load);
                       this.Closed   +=   new   System.EventHandler(this.Form1_Closed);

}

///   <summary>
///   清理所有正在使用的资源。
///   </summary>
protected   override   void   Dispose(   bool   disposing   )
{
if(   disposing   )
{
if   (components   !=   null)  
{
components.Dispose();
}
}
base.Dispose(   disposing   );
}

#region   Windows   窗体设计器生成的代码
///   <summary>
///   设计器支持所需的方法   -   不要使用代码编辑器修改
///   此方法的内容。
///   </summary>
private   void   InitializeComponent()
{
                       System.Resources.ResourceManager   resources   =   new   System.Resources.ResourceManager(typeof(Form1));
                       this.button1   =   new   System.Windows.Forms.Button();
                       this.axWebBrowser1   =   new   AxSHDocVw.AxWebBrowser();
                       this.openFileDialog1   =   new   System.Windows.Forms.OpenFileDialog();
                       ((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();
                       this.SuspendLayout();
                       //  
                       //   button1
                       //  
                       this.button1.Anchor   =   ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom   |   System.Windows.Forms.AnchorStyles.Left)));
                       this.button1.Location   =   new   System.Drawing.Point(36,   304);
                       this.button1.Name   =   "button1 ";
                       this.button1.TabIndex   =   0;
                       this.button1.Text   =   "button1 ";
                       this.button1.Click   +=   new   System.EventHandler(this.button1_Click);
                       //  
                       //   axWebBrowser1
                       //  
                       this.axWebBrowser1.Anchor   =   ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top   |   System.Windows.Forms.AnchorStyles.Bottom)  
                               |   System.Windows.Forms.AnchorStyles.Left)  
                               |   System.Windows.Forms.AnchorStyles.Right)));
                       this.axWebBrowser1.Enabled   =   true;
                       this.axWebBrowser1.Location   =   new   System.Drawing.Point(12,   4);
                       this.axWebBrowser1.OcxState   =   ((System.Windows.Forms.AxHost.State)(resources.GetObject( "axWebBrowser1.OcxState ")));
                       this.axWebBrowser1.Size   =   new   System.Drawing.Size(576,   280);
                       this.axWebBrowser1.TabIndex   =   1;
                       this.axWebBrowser1.NavigateComplete2   +=   new   AxSHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.axWebBrowser1_NavigateComplete2);
                       //  
                       //   Form1
                       //  
                       this.AutoScaleBaseSize   =   new   System.Drawing.Size(6,   14);
                       this.ClientSize   =   new   System.Drawing.Size(616,   346);
                       this.Controls.Add(this.axWebBrowser1);
                       this.Controls.Add(this.button1);
                       this.Name   =   "Form1 ";
                       this.Text   =   "Form1 ";
                       this.Load   +=   new   System.EventHandler(this.Form1_Load);
                       this.Closed   +=   new   System.EventHandler(this.Form1_Closed);
                       ((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();
                       this.ResumeLayout(false);

               }
#endregion

///   <summary>
///   应用程序的主入口点。
///   </summary>
[STAThread]
static   void   Main()  
{
Application.Run(new   Form1());
}

               private   void   button1_Click(object   sender,   System.EventArgs   e)
               {
                       String     strFileName;

                       openFileDialog1.FileName   =   " ";
                       openFileDialog1.ShowDialog();
                       strFileName   =   openFileDialog1.FileName;
             
                       if(strFileName.Length   !=   0)
                       {
                               Object   refmissing   =   System.Reflection.Missing.Value;
                               oDocument   =   null;
                               axWebBrowser1.Navigate(strFileName,   ref   refmissing   ,   ref   refmissing   ,   ref   refmissing   ,   ref   refmissing);
                       }
               }

               private   void   Form1_Load(object   sender,   System.EventArgs   e)
               {
                       button1.Text   =   "Browse ";
                       openFileDialog1.Filter   =   "Office   Documents(*.doc,   *.xls,   *.ppt)|*.doc;*.xls;*.ppt "   ;
                       openFileDialog1.FilterIndex   =   1;

               }

               private   void   Form1_Closed(object   sender,   System.EventArgs   e)
               {
                       oDocument   =   null;
               }

               private   void   axWebBrowser1_NavigateComplete2(object   sender,   AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event   e)
               {.
                       Object   o   =   e.pDisp;  
                       oDocument   =   o.GetType().InvokeMember( "Document ",BindingFlags.GetProperty,null,o,null);
                       Object   oApplication   =   o.GetType().InvokeMember( "Application ",BindingFlags.GetProperty,null,oDocument,null);
                       Object   oName   =   o.GetType().InvokeMember( "Name ",BindingFlags.GetProperty   ,null,oApplication,null);
               }


}
}

页码: 1