Project-->Add To Project-->Components and Controls... 添加控件
选 Registered ActiveX Controls
选 Windows Media Player 点Insert
打开资源,在工具条下面会发现一个Windows Media Player的控件图标
托一个到主对话框里
#include "wmpplayer4.h"
定义
CWMPPlayer4 m_WMPPlayer4;
#include "wmpcontrols.h"
BOOL CMPlayerDlg::OnInitDialog()
m_WMPPlayer4.SubclassDlgItem(IDC_OCX1,this); 子类化控件
m_WMPPlayer4.SetUiMode(_T("none"));
//添加一个按钮,播放mp3
void CMPlayerDlg::OnButton1()
{
if(m_WMPPlayer4.m_hWnd != NULL)
{
m_WMPPlayer4.SetUrl("http://www.cp007.com/yule/UploadFiles_2006/200601/20060122160526520.wma");
m_WMPPlayer4.SetFullScreen(FALSE);
m_WMPPlayer4.GetControls().play();
return;
}
}