工具:vs ,必须安装flash控件
1:随便建个MFC空项目,项目->添加类->activeX控件中的MFC类,点添加->下拉控件列表,选择shock wave object OK 完成.
2:打完资源对话框,工具箱,右点对话编辑器->选择项,com控件,选择shockwave flash object。
3:在工具箱拖个flash控件随便什么位置,绑定控件变量m_flashplayer;
4:在CXXXDlg::OnInitDialog函数中完成flash的调用,代码如下:
ShowWindow(SW_SHOWMAXIMIZED);
CRect rect;
GetWindowRect(rect); //先最大显示模式
m_FlashPlayer.MoveWindow(rect,true);
SetWindowLong(this->m_hWnd, GWL_STYLE, GetWindowLong(this->m_hWnd, GWL_STYLE) & WS_CAPTION);//去掉标题栏
CClientDC dc(this);
int horzres = dc.GetDeviceCaps(HORZRES);//获得象素长度
int vertres = dc.GetDeviceCaps(VERTRES);//宽度
//this->MoveWindow(0, 0, horzres, vertres);
m_FlashPlayer.SetWindowPos(&CWnd::wndTop, 0, 0, horzres, vertres, SWP_SHOWWINDOW);
//让flash全屏显示
TCHAR strCurDrt[500];
int nLen = ::GetCurrentDirectory(500,strCurDrt);
if( strCurDrt[nLen]!='' )
{
strCurDrt[nLen++] = '';
strCurDrt[nLen] = '';
}
CString strFileName = strCurDrt;
strFileName += "103x.swf"; //以上为获的绝对路径
m_FlashPlayer.LoadMovie(0, strFileName);//加载flash
//m_FlashPlayer.put_WMode(L"transparent");
//m_FlashPlayer.put_BackgroundColor(50);
m_FlashPlayer.Play(); //播放
九牛资源网 » MFC中播放flash简单例子