在何使winform中的flash控件(Shockwave Flash Object)的背景透明?

cwbboy 2005-09-21 05:58:29
该flash文件在网页中可实现透明,
 
 但在winform中始终无法透明,背景一直为白色。 设置了窗口模式(WMode)为Transparent 也不行。 

  背景色默认为-1 
...全文
1286 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
alan001 2006-01-07
  • 打赏
  • 举报
回复
学习
蒋晟 2006-01-07
  • 打赏
  • 举报
回复
VC中的MFC6.0不支持,但是从7.0开始支持透明的flash控件……
emilsong 2006-01-07
  • 打赏
  • 举报
回复
设置TransparencyKey为白色(你FLASH背景的颜色)
目前只发现这种方法可以。

顺便问个问题,FLASH控件没有响应鼠标的事件如何给它加上呢?
s5689412 2005-12-22
  • 打赏
  • 举报
回复
Currently I'm working on a project using C# and with a Flash front end. The transparency issue i have overcame and what is needed is in visual studio on the form transparency key which is near the bottom of the properties - need to set that as a color such as green and when the color is shown print screen then open up photo shop paste the image get the correct color of the green and set that color as the background in the flash movie. Also in visual studio set the form mode so it does not have title bar close or minimize box. Right now my app sends fs commands to c# to minimize close, and operations that c# needs to perform and all the interface is flash based and resizable. The flash uses xml for some of the interface related information and c# will do the brunt of the work of the app. The app now has a pretty cool look and feel and i have seen nothing yet like it. So far when the program runs it will have a transparent look for the alpha per pixel of 0% or 100% although not semi transparent say 50% which i would love to find an answer to that. In visual studio on the form if you set the transparency of the form to other than fully opaque it will mess up the look of the flash and display the color green semi transparent. As well on the photoshop side you want to make sure that the .png's used on the edges of the graphics are either fully opaque other wise it will display a green edge around the app when ran.

I'm not a pro on c#, but if anyone found this useful or even not i would greatly appreciate any information on sending data from c# to flash.

Hamish

from:http://weblogs.macromedia.com/mesh/archives/2003/05/integrating_fla_1.cfm
Aallonlin 2005-12-22
  • 打赏
  • 举报
回复
UP
coley 2005-12-21
  • 打赏
  • 举报
回复
顶,我也要弄明白
asakao 2005-11-21
  • 打赏
  • 举报
回复
帮着顶一下,我也很想知道答案!
很多光盘上的程序,比如电脑迷光盘,开头总有一段动画,用来展现企业品牌和LOGO之用。这个动画是Flash做的,而且嵌入到程序简直做到无缝融合,因为右键点击它也不会有那特有而烦人的Flash右键菜单。 因此将Flash融合到WinForm能够增强程序的多媒体效果和炫丽的外观。现在我们就来看看在C#桌面程序如何插入Flash视频,而且去掉烦人的右键菜单。 首先要插入Flash就必须使用Flash控件,在工具栏右键选择“选择项…”,然后在“COM组件”面板下点击“浏览”按钮,在本机电脑C:\WINDOWS\system32\Macromed\Flash\目录里选择Flash8.ocx(也有可能是Flash9F.ocx,版本不同所致),然后点击确定就可以了。但到这里还没有完,因为要使用Flash控件必须注册它。 在CMD里面输入如下: regsvr32 C:\WINDOWS\system32\Macromed\Flash\Flash8.ocx 系统会提示注册成功,这个时侯就可以在VS2008里面使用该控件了! 打开VS2008,新建一个Windows程序,然后把刚才我们选择的Flash控件Shockwave Flash Object拖到窗体,这时窗体会出现一个白色的矩形框,Name属性我们设置为Myflash,在里面可以播放我们需要的swf文件。 注意到该控件主要有几个属性: Name属性,这个是所有对象都会有的。 Menu属性,这个是Flash菜单项,默认值为true,也就是右键的时候会出现完整的Flash菜单,如果设置为False,则只出现最简的菜单(设置与关于)。 Move属性,这个属性是用来指定要播放的Flash文件的。 Playing属性,指定是否装在影片之后马上播放。 Quality属性,设置影片的质量。 Scalemode属性,设置影片的缩放模式。 Visible属性,设置影片控件的可视与否。 接下来我们在窗体放置一个按钮,Text属性设置为LoadSwf。双击添加事件代码如下: OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Flash文件|*.swf"; DialogResult dr = ofd.ShowDialog(); if (dr == DialogResult.OK) { Myflash.Movie = ofd.FileName; Myflash.Play(); } 这样当程序运行的时候点击按钮会要我们选择一个SWF文件,选择好后确定就自动播放了! 当然,我们还可以添加一些按钮,分别为Play,Pause Play按钮的播放功能如下: This.Myflash.Play(); Pause按钮的暂停功能如下: This.Myflash.StopPlay(); 这里就不再啰嗦了,各位园友可以自行去研究一些常用的功能。下面我们主要来讲解如何消去烦人的Flash右键菜单! 消去Flash右键菜单有两种方法(本人愚笨,到目前只发现这两种): 方法一: 这个方法比较复杂,也比较繁琐,主要是用到API函数的调用。代码如下: #region 去掉Flash右键菜单,API函数的声明 private const int GWL_WNDPROC = -4; public delegate IntPtr FlaWndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); private IntPtr OldWndProc = IntPtr.Zero; private FlaWndProc Wpr = null; [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, FlaWndProc wndProc); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr CallWindowProc(IntPtr wndProc, IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); private IntPtr FlashWndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam) { if(msg == 516) //516就是对应鼠标的右键,当然你也可以用0X0204右键鼠标的16进制编码 return (IntPtr)0; //什么都不做 return CallWindowProc(OldWndProc, hWnd, msg, wParam, lParam); } #endregion 将以上代码放在窗体声明字段的地方。 注:要调用API函数就必须引用一个命名空间: using System.Runtime.InteropServices; 然后在窗体的载入事件里面添加如下代码: private void Flash_Load(object sender, EventArgs e) { this.Wpr = new FlaWndProc(this.FlashWndProc); this.OldWndProc = SetWindowLong(Myflash.Handle, GWL_WNDPROC, Wpr); //关联flash控件 } 如此则大功告成,看看是不是把Flash右键菜单给去掉了!! 方法二: 这个方法很简单,也很灵活,主要用到继承和重写等面向对象的核心内容。 首先声明一个类,让它去继承AxShockwaveFlashObjects.AxShockwaveFlash,该类是实例化Flash控件生成的类。该类包含各种Flash的事件和属性,在这里我们只对右键菜单的事件感兴趣,因此我们去重写该事件。 类的代码如下: public class FlashRightKey : AxShockwaveFlashObjects.AxShockwaveFlash { //定义一个公共类FlashRightKey(类名自己定义)来继承AxShockwaveFlashObjects.AxShockwaveFlash(在实例化Shockwave Flash Object控件后生成)类 protected override void WndProc(ref Message m) //重载WndProc方法(此方法即消息处理机制) { if (m.Msg == 0X0204) //0×0204即鼠标右键的16进制编码 return; //返回并不输出 else base.WndProc(ref m); //如果不是右键的话则返回正常的信息 } } 类写好了,我们要在Flash控件里面使用它,必须在实例化Flash控件的时候用如下代码(写在Flash.Designer.cs文件相应的地方): private FlashRightKey MyFlash2; this.MyFlash2 = new Namespace.FlashRightKey(); 注:Namespace为工程项目的命名空间。 剩下的就和不用我多说了,大功告成,实现了Flash控件去掉右键菜单。 以上代码在 XP+VS2008+Flash8播放器 调试通过。 本文也只是抛砖引玉,至于如何获取点击事件以及和其他控件的通信则是比较高深一点的知识了,各位朋友互相勉励,想更高深的知识挺进!

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧