www.gusucode.com > 高级文件属性操作的VC例子代码源码程序 > 高级文件属性操作的VC例子代码源码程序\code\FileList.cpp
// FileList.cpp : implementation file // Download by http://www.NewXing.com #include "stdafx.h" #include "FileList.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CFileList CFileList::CFileList() { m_strFilter = "*.*"; } CFileList::~CFileList() { } BEGIN_MESSAGE_MAP(CFileList, CListBox) //{{AFX_MSG_MAP(CFileList) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFileList message handlers void CFileList::FillListBox(CString csPath) { int nDir = 0; if (csPath.Right(1) != '\\') csPath += '\\'; csPath += m_strFilter; ResetContent(); CFileFind FoundFiles; BOOL bContinue = FoundFiles.FindFile(csPath); while (bContinue == TRUE) { bContinue = FoundFiles.FindNextFile(); int nIndex = GetCount(); if (FoundFiles.IsDirectory()) continue; this->AddString(FoundFiles.GetFileName()); //, nIcon); } FoundFiles.Close(); } void CFileList::SetFilter(CString strFilter) { m_strFilter = strFilter; }