qq_29460631 2015-07-10 12:54 采纳率: 50%
浏览 1847
已结题

VS2008制作多媒体播放器,WindowsMediaPlayer控件按钮出错

播放媒体后,按停止键(WindowsMediaPlayer),再将鼠标移至菜单栏(没有点击),立刻又继续播放
以下是部分代码:
BOOL CPLAYERDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
skinppLoadSkin(_T("blue.ssk"));//blue.ssk为项目下的皮肤文件,

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
m_control=static_cast<CWMPControls>(m_play.GetControls());
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
    CString strAboutMenu;
    strAboutMenu.LoadString(IDS_ABOUTBOX);
    if (!strAboutMenu.IsEmpty())
    {
        pSysMenu->AppendMenu(MF_SEPARATOR);
        pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
}

// Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE);         // Set big icon
SetIcon(m_hIcon, FALSE);        // Set small icon

// TODO: Add extra initialization here

return TRUE;  // return TRUE  unless you set the focus to a control

}
void CPLAYERDlg::OnPlay()
{
// TODO: Add your control notification handler code here
CON=1;
CString str;
if(m_list.GetCount()<=0)MessageBox("请先打开最少一个媒体文件!","Warning",MB_OK);
else
{
KillTimer(1);
if(m_list.GetCurSel()<0)
{
m_list.SetCurSel(0);
}
index=m_list.GetCurSel();
m_list.GetText(index,str);
m_play.SetUrl(str);
SetTimer(1,1000,NULL);
}

}
void CPLAYERDlg::OnBnClickedSequence()
{
// TODO: 在此添加控件通知处理程序代码
FG=0;
}

void CPLAYERDlg::OnBnClickedRandom()
{
// TODO: 在此添加控件通知处理程序代码
FG=1;
}

void CPLAYERDlg::OnBnClickedCycle()
{
// TODO: 在此添加控件通知处理程序代码
FG=2;
}

void CPLAYERDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
int index1=m_play.GetPlayState();
if(index1==1)
{
if(FG==0)
{
CString str;
int index=m_list.GetCurSel()+1;
if(index>=m_list.GetCount())
index=0;
m_list.GetText(index,str);
m_play.SetUrl(str);
m_list.SetCurSel(index);
}
else if(FG==1)
{
srand(time(0));
m_list.SetCurSel(rand()%m_list.GetCount());
m_list.GetText(m_list.GetCurSel(),m_pathname);
m_play.SetUrl(m_pathname);
}
else if(FG==2)
{
m_list.GetText(m_list.GetCurSel(),m_pathname);
m_play.SetUrl(m_pathname);
}
else;
}
CDialog::OnTimer(nIDEvent);
}

  • 写回答

3条回答 默认 最新

  • frank_20080215 2015-07-10 14:23
    关注

    添加菜单处理函数,禁止任何播放操作

    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大