zoukankan      html  css  js  c++  java
  • C# winfrom中Flash播放使用axShockwaveFlash控件设置透明XP出现白色背景解决办法,仿QQ魔法表情效果

     //播放时  图片周围有锯齿白边出现    反锯齿处理暂无解决办法、 如有大神 请给我留言

    新Form    AllowDrop True

    引用using System.IO;

    拖1个Button

            public Form1()
            {
                InitializeComponent();
            }

        string fileName;
            String extendedName;
            String fileName1;

            private void button1_Click(object sender, EventArgs e)
            {
                OpenFileDialog ofd = new OpenFileDialog();                //new一个方法
                ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //定义打开的默认文件夹位置
                ofd.ShowDialog();          //显示打开文件的窗口
                fileName = ofd.FileName;                //获得选择的文件路径
                extendedName = Path.GetExtension(fileName);       //获得文件扩展名
                fileName1 = Path.GetFileName(fileName);


                PlayFlash f = new PlayFlash(fileName);
                f.Show();


            }

     //拖入

    private void Form1_DragEnter(object sender, DragEventArgs e)
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    e.Effect = DragDropEffects.Copy;
                }
            }

    //拖入操作释放

            private void Form1_DragDrop(object sender, DragEventArgs e)
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[] MyFiles = (string[])(e.Data.GetData(DataFormats.FileDrop));
                    if (MyFiles.Length > 0)
                    {
                        PlayFlash f = new PlayFlash(MyFiles[0]);//播放窗体传值
                        f.Show();//播放窗体显示
                    }
                }
            }

    新建Form

    拉一个webBrowser

    拖1个timer

    设计Form背景为透明等属性

            /// <summary>
            /// 存放Flash路径
            /// </summary>
            string playFile = "";


            public string Isplay;
          
           

            /// <summary>
            /// 获取Flash路径并渲染窗体
            /// </summary>
            /// <param name="file"></param>
            public Form1(string file)
            {
                playFile = file;
                InitializeComponent();
            }

     private void Form1_Load(object sender, EventArgs e)
            {
                //新的文档
                webBrowser1.Navigate("about:blank");

                //判断文档是否在加载
                while (webBrowser1.IsBusy)
                {
                    Application.DoEvents();
                }
              
                webBrowser1.Document.Write("<HTML>");
                webBrowser1.Document.Write("<HEAD>");
                webBrowser1.Document.Write("<TITLE>");
                webBrowser1.Document.Write("</TITLE>");
                webBrowser1.Document.Write("<script type='text/javascript' language='javascript'>");
                webBrowser1.Document.Write("function a() {");
                webBrowser1.Document.Write("var ab= document.swf.IsPlaying();");
                webBrowser1.Document.Write("var d = document.getElementById('xxx');");
                webBrowser1.Document.Write("d.value = ab;");
                webBrowser1.Document.Write(" }");
                webBrowser1.Document.Write("</script>");
                webBrowser1.Document.Write("</HEAD>");
                webBrowser1.Document.Write("<BODY>");
                //网页效果输出Flahs
                webBrowser1.Document.Write(string.Format("<object  classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="swf"> <param name="wmode" value="transparent"><param name="movie" value="{0}"> <param name="quality" value="high"><param name="LOOP" value="false" /></object>", playFile));
                webBrowser1.Document.Write("<input id="xxx" type="hidden" runat="server" /></BODY>");
                webBrowser1.Document.Write("</HTML>");


                timer1.Interval = 50;
                timer1.Enabled = true;

            }


            int sum = 0;

            private void timer1_Tick(object sender, EventArgs e)
            {
                webBrowser1.Document.InvokeScript("a");

                Isplay = webBrowser1.Document.All["xxx"].GetAttribute("value");
                if (Isplay == "false")
                {
                        timer1.Enabled = false;
                        this.Close();
                }
                sum = sum + 1;
                if (sum > 100)
                {
                    timer1.Enabled = false;
                    this.Close();
                }
            }

  • 相关阅读:
    (转)一文讲清TCP/IP 协议
    Java框架之Spring Boot和Spring Cloud区别
    php大力力 [006节]初步接触认识phpMyAdmin
    php大力力 [005节] php大力力简单计算器001
    php大力力 [004节]PHP常量MAMP环境下加载网页
    php大力力 [003节]php在百度文库的几个基础教程mac环境下文本编辑工具
    php大力力 [002节]mac php环境安装,mamp安装 ,phpMyAdmin启动
    php大力力 [001节]2015-08-21.php在百度文库的几个基础教程新手上路日记 大力力php 大力同学 2015-08-21 15:28
    C# DataSet与DataTable的区别和用法 ---转载
    【SqlServer】利用sql语句附加,分离数据库-----转载
  • 原文地址:https://www.cnblogs.com/taikongbai/p/3519504.html
Copyright © 2011-2022 走看看