.net 2003
我做了个资源管理器的简单MFC程序 可是老是报错
c:\Documents and Settings\dell\My Documents\Visual Studio Projects\FileManager\FolderTreeCtrl.cpp(84): error C2065: “faDirectory” : 未声明的标识符
c:\Documents and Settings\dell\My Documents\Visual Studio Projects\FileManager\FolderTreeCtrl.cpp(48): error C2065: “SearchRec” : 未声明的标识符
c:\Documents and Settings\dell\My Documents\Visual Studio Projects\FileManager\FolderTreeCtrl.cpp(48): error C2065: “TSearchRec” : 未声明的标识符
找了很久也没搞明白怎么声明他们
发现好象是dephi的东东
源程序如下
// FolderTreeCtrl.cpp : 实现文件
//
#include "stdafx.h"
#include "FileManager.h"
#include "FolderTreeCtrl.h"
#include ".\foldertreectrl.h"
// CFolderTreeCtrl
IMPLEMENT_DYNAMIC(CFolderTreeCtrl, CTreeCtrl)
CFolderTreeCtrl::CFolderTreeCtrl()
{
}
CFolderTreeCtrl::~CFolderTreeCtrl()
{
}
BEGIN_MESSAGE_MAP(CFolderTreeCtrl, CTreeCtrl)
END_MESSAGE_MAP()
// CFolderTreeCtrl 消息处理程序
void CFolderTreeCtrl::ExploreDir(const CString& strDir , HTREEITEM hParent)
{
TV_INSERTSTRUCT tvstruct;
CString strSearchDir;
HTREEITEM hIT=GetChildItem(hParent);
HTREEITEM hTemp;
while(hIT!=NULL)
{
hTemp=GetNextSiblingItem(hIT);
DeleteItem(hIT);
hIT=hTemp;
}
if(hParent!=GetRootItem())
strSearchDir=strDir+_T("\\");
else
strSearchDir="";
BOOL bDir=FALSE;
HTREEITEM hThisItem;
TSearchRec SearchRec;
if(strSearchDir=="")
{
char DriveChar;
UINT DriveType;
char lpRootPathName[256]="";
DWORD DriveBits=(DWORD)GetLogicalDrives();
for(DWORD DriveNum=0,Num=1;DriveNum<26;DriveNum++,Num=Num*2)
{
if((Num&DriveBits)==0) continue;
DriveChar=char(DriveNum)+'a';
memset(lpRootPathName,0,256);
lpRootPathName[0]=DriveChar;
strcat(lpRootPathName,":\\");
DriveType=GetDriveType((LPCTSTR)lpRootPathName);
switch(DriveType)
{
case DRIVE_REMOVABLE;
case DRIVE_FIXED;
case DRIVE_REMOTE;
case DRIVE_CDROM;
case DRIVE_RAMDISK;
bDir=TRUE;
tvstruct.item.iImage =3;
tvstruct.item.iSelectedImage=3;
tvstruct.hParent=hParent;
tvstruct.hInsertAfter=TVI_LAST;
tvstruct.item.pszText =(LPCTSTR)(LPCTSTR)lpRootPathName;
tvstruct.item.mask =TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_TEXT;
hThisItem=InsertItem(&tvstruct);
break;
}
}
}
else
{
int Status=YS_FindFirst(SlashSep(strSearchDir,"*.*"),faDirectory,&SearchRec);
TRY
while(Status==0)
{
if((SearchRec.Attr&faDirectory)==faDirectory)
{
if((SearchRec.Name!='.')&&(SearchRec.Name!=".."))
{
bDir=TRUE;
tvstruct.item.iImage =1;
tvstruct.item.iSelectedImage=2;
tvstruct.hParent=hParent;
tvstruct.hInsertAfter=TVI_LAST;
tvstruct.item.pszText =(LPCTSTR)(LPCTSTR)SearchRec.Name;
tvstruct.item.mask =TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_TEXT;
hThisItem=InsertItem(&tvstruct);
}
}
Status=YS_FindNext(&SearchRec);
}
CATCH_ALL(e)
YS_FindClose(SearchRec);
END_CATCH_ALL
}
if(bDir)
{
CString strFullSearchPath;
int nImage,nSelectedImage;
hThisItem=GetChildItem(hParent);
CString strDirInfo,strFileName;
while(hThisItem!=NULL)
{
GetItemImage(hThisItem,nImage,nSelectedImage);
if((nImage==1)||(nImage==3))//为目录
{
tvstruct.hParent=hThisItem;
tvstruct.hInsertAfter=TVI_LAST;
tvstruct.item.iImage =1;
tvstruct.item.iSelectedImage=2;
tvstruct.item.pszText =_T("1");
tvstruct.item.mask =TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_TEXT;
InsertItem(&tvstruct);
}
hThisItem=GetNextSiblingItem(hThisItem);
}
}
return;
}