MediaPlayer ActiveX 控件在对话框中时需要注意

来源:互联网 发布:注销淘宝账号 编辑:程序博客网 时间:2024/04/29 19:22

当播放器取平播放时,按下某一个键都会使得CPU达到100%,据我分析是因为MediaPlayer控件和对话框都要获取按键事件(WM_KEYDOWN),而且做要做互斥的操作,所以可能造成了线程的死锁。

在对话框对象中重载PreTranslateMessage函数,截取WM_KEYDOWN可以解决此问题。例如:

BOOL CMyMediaPlayerDlg::PreTranslateMessage(MSG* pMsg)
{
 // TODO: Add your specialized code here and/or call the base class
 m_tt.RelayEvent(pMsg);
 if(pMsg->message==WM_KEYDOWN)
 { 
  if(pMsg->wParam==VK_ESCAPE)
   m_mediaplayer.SetFullScreen(FALSE);
  else
   return TRUE;
 }
 else
  CDialog::PreTranslateMessage(pMsg);
}

如果要隐藏MediaPlayer控件,不能简单的使用ShowWindow(SW_HIDE)方法,而要用m_mediaplayer.SetUiMode("Invisible");

原创粉丝点击