功能:实现第一代简小AVI的播放
打开通用对话框选择播放文件,点击单选按钮"开始"即开始播放,左侧可以设置循环播放次数。
文件播放完毕后,文件名显示在ListBox上,双击对应的选项改变播放路径。
HOTKEY控件可以设置相应快捷键实现程序在后台时快速显示。
相关代码:
void CMFCCtrlDlg::OnOpenfile()
{
// TODO: Add your control notification handler code here
CHAR szFilter[] = "AVI File(*.avi)|*.avi|ALL File(*.*)|*.*||";
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, szFilter);
if ( IDOK != dlg.DoModal())
{
return;
}
//获取选择的文件到编辑框中
m_PathName = dlg.GetPathName();
UpdateData(FALSE);
//添加文件名到列表框中,并返回选项值
int nItem = m_List_History.AddString(dlg.GetFileName());
//保存文件路径到选项
CString * pstrFilePath = new CString;
*pstrFilePath = dlg.GetPathName( );
m_List_History.SetItemData( nItem,
(DWORD)pstrFilePath );
}
void CMFCCtrlDlg::OnRadioStart()
{
// TODO: Add your control notification handler code here
m_WndAnimate.Open(m_PathName); //打开文件
if (m_check_loop.GetCheck()) //如果循环播放复选框被勾选刚判断combobox选项的播放次数
{
int sCur = m_ComboBox_LoopNum.GetCurSel();
switch(sCur)
{
case 0:
m_WndAnimate.Play(0,-1,-1);
break;
case 1:
m_WndAnimate.Play(0,-1,1);
break;
case 2:
m_WndAnimate.Play(0,-1,2);
break;
case 3:
m_WndAnimate.Play(0,-1,3);
break;
case 4:
m_WndAnimate.Play(0,-1,5);
break;
case 5:
m_WndAnimate.Play(0,-1,10);
break;
}
}
else
{
m_WndAnimate.Play(0,-1,1);
}
}
void CMFCCtrlDlg::OnRadioStop()
{
// TODO: Add your control notification handler code here
m_WndAnimate.Stop();
m_WndAnimate.Close();
}
void CMFCCtrlDlg::OnCheck1()
{
// TODO: Add your control notification handler code here
BOOL bCheck = m_check_loop.GetCheck();
m_ComboBox_LoopNum.EnableWindow(bCheck);
}
void CMFCCtrlDlg::OnDblclkList1()
{
// TODO: Add your control notification handler code here
int nSel = m_List_History.GetCurSel( );
if( LB_ERR == nSel )
{
return;
}
//获取选择项的路径
CString * pstrPathName = ( CString * )
m_List_History.GetItemData( nSel );
//设置到EDIT中
m_PathName = *pstrPathName;
UpdateData( FALSE );
}
void CMFCCtrlDlg::OnButtonHotkey()
{
// TODO: Add your control notification handler code here
//获取设置的热键
DWORD nHotKey = m_HotKey.GetHotKey( );
//设置成程序的热键
SendMessage( WM_SETHOTKEY, nHotKey );
}
/Files/goos/MFCCtrl.zip