you by the framework.
void CDlgCtrlDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CDlgCtrlDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CDlgCtrlDlg::OnOpenFile()
{
// TODO: Add your control notification handler code here
char lpszFilter[]="视频(*.avi)|*.avi|视频(*.rmvb)|*.rmvb|所有文件(*.*)|*.*||";
CFileDialog dlg(TRUE,NULL,NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
lpszFilter);
if(IDOK!=dlg.DoModal()) return;
//编辑框中更新文件路径
m_strFilePath=dlg.GetPathName();
UpdateData(FALSE);
//列表加入文件名
//m_listFileName.AddString(dlg.GetFileName());
CString strName=dlg.GetFileName();
if (LB_ERR==m_listFileName.FindString(-1,strName))
{
//添加文件名称
int nIndex=m_listFileName.AddString(strName);
CString *pPath=new CString;
*pPath=m_strFilePath;
//通过附加数据,保存文件路径
m_listFileName.SetItemData(nIndex,(DWORD)pPath);
}
//动画控件播放动画
play();
}
void CDlgCtrlDlg::play()
{
int nCount=1;//保存播放的次数
if (m_btnReplay.GetCheck())
{
int nSel=m_cboPlayCount.GetCurSel();
switch(nSel)
{
case 0://重复播放
nCount=-1;
break;
case 1://重复一次
nCount=2;
break;
case 2://重复两次
nCount=3;
break;
}
}
m_animateVideo.Open(m_strFilePath);
m_animateVideo.Play(0,-1,nCount);
}
void CDlgCtrlDlg::OnDblclkListFilename()
{
//获取双击时,当前的选择项
int nSel=m_listFileName.GetCurSel();
if (LB_ERR==nSel)return;
//播放当前选中的文件
CString *pPath=(CString*) m_listFileName.GetItemData(nSel);
m_strFilePath=*pPath;
//播放
play();
UpdateData(FALSE);
AfxMessageBox(*pPath);
}
void CDlgCtrlDlg::OnClose()
{
//字符串路径在附加数据里,关闭时要删除
for (int i=0;i
示例2: 1、新建MFC对话框应用程序DlgCtrl2。 2、可视化编辑界面控件
 3、ctrl+w 绑定控件对应的成员变量
 4、ctrl+w 绑定列表框项的双击事件和按钮的单击事件
 5、***Dlg.cpp中的主要实现代码(部分是自动生成的)
#include "stdafx.h"
#include "DlgCtrl2.h"
#include "DlgCtrl2Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAbout |