我把源码上传到http://u.115.com/file/t187b15d56语法没问题就是不知为什么没效果,求改正
解决方案 »
- vc应用dbf数据库的问题
- 谁能将EastDraw转换成OCX?然后改改加个输入输出接口,大家就可以方便用它来做电子白板了
- 再求:VC++6.0调试的问题
- 打包
- 有关源程序英文化的问题
- 怎么使用ATL编写的COM/COM+组件使其能返回ADOrecordset记录集给客户端?
- VC++ Dll 问题:为什么在VB中调用提示“找不到入口点”?
- help !!有分送
- 能否在分别运行winxp、win8两个计算机之间远程调试程序?
- 伸出充满友爱的援助之手,顺便看看你对控件的熟悉程度如何。多好的事情啊,开来显示一下你助人为乐的高尚品质吧!
- 我想问几个关于listview的消息
- 三维坐标转换成二维坐标问题
{
CTreeCtrl*pTree=(CTreeCtrl*)GetDlgItem(IDC_TREE);
//下面进行搜索实现文件遍历
CFileFind filefind;
CString filepath;
CString filename = strl;
tvinsert.hParent=h;
tvinsert.item.iImage=0;
tvinsert.item.iSelectedImage=0;
BOOL flag=filefind.FindFile(filename );//查找文件
while(flag)
{
flag=filefind.FindNextFile();
if(filefind.IsDots())
continue;
else
if(filefind.IsDirectory())//是目录则需要对目录继续遍历
{
filename=filefind.GetFileName();
tvinsert.item.pszText=strdup(filename);
tvinsert.hParent=h;
hDad=pTree->InsertItem(&tvinsert);
Findfile(filefind.GetFilePath()+"\\*.*",hDad);//递归查找文件
}
else
{
tvinsert.hParent=h;
filename=filefind.GetFileName();//得到文件名
tvinsert.item.pszText=strdup(filename);
pTree->InsertItem(&tvinsert);//插入一项
}
}
}
__int64 FolderSize=0;
int FilesContained=0;
int FoldersContained=0;
////
void FolderWalkRecurse(LPDIRWALKDATA pDW)
{
char szCurrDir[MAX_PATH];
HANDLE hFind;
char tmp[MAX_PATH];// set new path
sprintf(szCurrDir,"%s%s",FolderPath,"*.*");
hFind=FindFirstFile(szCurrDir,&pDW->FindData);
pDW->fOK=(hFind!=INVALID_HANDLE_VALUE);
while(pDW->fOK) // found
{ // till found
pDW->fIsDir=pDW->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
GetFilePart(FolderPath,tmp);// dir for recurse!
sprintf(tmp,"%s",pDW->FindData.cFileName);
if(strcmp(tmp,".") && strcmp(tmp,"..")) //not
{
if(pDW->fIsDir)
{
FoldersContained++;
}
else
{
FolderSize+=(pDW->FindData.nFileSizeHigh<<32) +
pDW->FindData.nFileSizeLow;
FilesContained++;
}
}
pDW->fOK=FindNextFile(hFind,&pDW->FindData);
}
if(hFind!=INVALID_HANDLE_VALUE) FindClose(hFind);// handle bad
if(pDW->fRecurse)
{// handle OK.get the first child directory
sprintf(szCurrDir,"%s%s",FolderPath,"*.*");
hFind=FindFirstChildDir(szCurrDir,&pDW->FindData);
pDW->fOK=(hFind!=INVALID_HANDLE_VALUE);
while (pDW->fOK)
{ // change into the child directory
sprintf(szCurrDir,"%s%s\\",FolderPath,pDW->FindData.cFileName);
strcpy(FolderPath,szCurrDir);
// AfxMessageBox(CString("enter Directory")+FolderPath,MB_OK);
FolderWalkRecurse(pDW);// Perform the recursive walk.
// change back to child's parent directory//
GetPathPart(FolderPath);
// AfxMessageBox(CString("leave Directory ")+FolderPath,MB_OK);
pDW->fOK=FindNextChildDir(hFind,&pDW->FindData);
}
if (hFind!=INVALID_HANDLE_VALUE) FindClose(hFind);
}
}
////
void FolderWalk(char *RootPath,BOOL fRecurse)
{
DIRWALKDATA DW;
// set new path
strcpy(FolderPath,RootPath);
// call the recursive function to walk the subdirectory
DW.fRecurse=fRecurse;
FolderWalkRecurse(&DW);
}、、
typedef struct
{
HWND hwndTreeLB;
BOOL fIsList;
BOOL fRecurse;
BOOL fOK;
BOOL fIsDir;
WIN32_FIND_DATA FindData;
}DIRWALKDATA, * LPDIRWALKDATA;
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
m_imageList.Create(16,16,0,8,8);
hIcon=AfxGetApp()->LoadIcon(IDI_ICON1);
m_imageList.Add(hIcon);
CTreeCtrl*pTree=(CTreeCtrl*)GetDlgItem(IDC_TREE);
pTree->SetImageList(&m_imageList,TVSIL_NORMAL);
//开始显示树形视图控件
tvinsert.hParent=NULL;
tvinsert.hInsertAfter=TVI_LAST;
tvinsert.item.mask=TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_TEXT;
tvinsert.item.hItem=NULL;
tvinsert.item.state=0;
tvinsert.item.stateMask=0;
tvinsert.item.cchTextMax=6;
tvinsert.item.iSelectedImage=1;
tvinsert.item.cChildren=0;
tvinsert.item.lParam=0;
//显示第一层
tvinsert.item.pszText="D:\\";
tvinsert.item.iImage=0;
tvinsert.item.iSelectedImage=0;
hDad=pTree->InsertItem(&tvinsert);
CString filepath="D:\\*.*";
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
Findfile("D:\\*.*",hDad); return TRUE; // return TRUE unless you set the focus to a control
}