Winform 中显示Flash并不象Web中显示那么简单,开发时还是要注意的。以下为最基本的步骤:
1.工具箱中,添加Com组件ShockwaveFlash
C:/WINDOWS/system32/Macromed/Flash/Flash10c.ocx
Regsvr32 C:/WINDOWS/system32/Macromed/Flash/Flash10c.ocx
2.regsvr32.exe c:/windows/system32/mci32.ocx
下载地址:http://www.xdowns.com/go/119.asp?url=uploadFile/2008-3/MCI32.rar
3.清理解决方案,重新生成,直至引用的AxShockwaveFlashObjects的叹号消失
4.添加控件axShockwaveFlash1,并显示Flash
flashBox.Movie = Application.StartupPath + "//flash//jinyu.swf";
5.实现右键全屏
(1)添加contextMenuStrip1
(2)全屏和取消全屏
private void fullScreenToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
{
this.TopMost = true;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
flashBox.Width = Screen.PrimaryScreen.Bounds.Width;
flashBox.Height = Screen.PrimaryScreen.Bounds.Height;
}
private void CancelSceenToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
{
this.TopMost = false;
this.FormBorderStyle = FormBorderStyle.Sizable;
this.WindowState = FormWindowState.Normal;
flashBox.Width = this.Width;
flashBox.Height = this.Height;
}
(3)在axShockwaveFlash1的属性contextMenuStrip设置contextMenuStrip1值