[cpp] view plain copy print?
CString CTestDlg::brow(LPCTSTR filter)
{
OPENFILENAME ofn
TCHAR szFilename[512]=_T("")
ZeroMemory(&ofn, sizeof(OPENFILENAME))
ofn.lStructSize = sizeof(OPENFILENAME)
ofn.hwndOwner = ::AfxGetMainWnd()->m_hWnd
ofn.lpstrFile = szFilename
ofn.nMaxFile = sizeof(szFilename)
ofn.lpstrFilter = filter
ofn.nFilterIndex = 1
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = NULL
ofn.lpstrDefExt=NULL
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY
GetOpenFileName(&ofn)
if(lstrlen(ofn.lpstrFile)>0)
{
return ofn.lpstrFile
}
return _T("")
}
[cpp] view plain copy print?
void CTestDlg::OnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE)
m_File=brow(_T("所有文件(*.*)|*.*\0\0"))
UpdateData(false)
}
[cpp] view plain copy print?
在TestDlg.h添加如下代码:
[cpp] view plain copy print?
CString brow(LPCTSTR filter)
在ResourceView里,双击Toolbar,双击IDR_MAINFRAME,
就出现了工具条编辑界面,默认的最右边那个灰按钮就是用来添加新按钮的,
双击它,会d出对话框让你给新按钮取个ID,取完后关掉对话框
就会多出一个按钮,你可以在这个界面下给按钮画下简单的图案
m_MusicData.clear() // vector<CString>m_MusicData//存储歌曲列表数据,以便下次读取// TODO: 在此添加控件通知处理程序代码
CFileDialog m_Dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT
| OFN_ALLOWMULTISELECT, NULL, NULL)
if (m_Dlg.DoModal() == IDOK)
{
POSITION pos
pos = m_Dlg.GetStartPosition()
while (pos)
{
CString m_Path = m_Dlg.GetNextPathName(pos)
//判断是否为MP3文件
if (m_Path.Find(_T(".mp3"))<0)
{
continue
}else
{
//这里去添加到列表
m_listbox.InsertString(m_listbox.GetCount(), m_Path)
m_listbox.SetCurSel(m_listbox.GetCount() - 1)
}
}
}
//这里去更新歌曲列表数据
for (int i = 0i <m_listbox.GetCount()i++)
{
CString str
m_listbox.GetText(i,str)
m_MusicData.push_back(str)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)