C# Flash的背景透明处理

现在发现VB真的很方便,C#虽然也不错,但是对flash的处理,和一些控件的使用还是不如VB方便!在VB上,flash的透明处理方便,只需修改flash控件shockwaveFlash的WMode属性:wmode = Transparent,但是在C#中,这样设置,flash控件根本没反应!上网,百度、谷歌,搜搜搜!没有得到解决方案,但是搜到了一个控件 f_in_box_lib.dll!虽然知道它支持flash背景透明,但是只有一个控件在手,没有相关说明,相当于授之以鱼,而无渔!没办法,直接访问f_in_box官网http://www.f-in-box.com/dotnet/(f_in_box的.net版本),看了一下帮助!找到了相关的代码:

分两步:

1.  WMode = Transparent (在属性列表中设置)

2. 响应f_in_box_lib的OnPaintStage事件,并添加代码

 if (f_in_box__lib.PaintStage.PrePaint == stage)
   {
    f_in_box__lib.f_in_box__control f_in_box__control = (f_in_box__lib.f_in_box__control)sender;

    using (Bitmap b = new Bitmap(Width, Height))
    {
     using (Graphics g = Graphics.FromImage(b))
     {
      PaintEventArgs pea = new PaintEventArgs(g, new Rectangle(f_in_box__control.Location, f_in_box__control.Size));

      this.OnPaintBackground(pea);
      this.OnPaint(pea);

      g.DrawImage(
       pictureBox1.Image,
       new Rectangle(pictureBox1.Location, pictureBox1.Size),
       new Rectangle(new Point(0, 0), pictureBox1.Image.Size),
       GraphicsUnit.Pixel);

      Canvas.DrawImage(
       b,
       new Rectangle(new Point(0, 0), f_in_box__control.Size),
       new Rectangle(f_in_box__control.Location, f_in_box__control.Size),
       GraphicsUnit.Pixel);
     }
    }
   }

这样就实现了flash的背景透明!

f_in_box官网实现了Demo下载,并附有源代码!如果上述步骤还不能帮助你的话,就到官网下载Demo!唯一的缺点就是下载速度忒慢!有时还达不到1kb/s!

原文地址:https://www.cnblogs.com/CPFlying/p/1685731.html