1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| void __fastcall TFormPrincipale::AddChild(TTreeNode *Node1, char *NomDir)
{
static int NumNode = 1;
TTreeNode *Node2;
WIN32_FIND_DATA FileData;
HANDLE hSearch;
int On = 0;
char szNewPath[MAX_PATH];
char szHome[MAX_PATH];
sprintf(szHome, "%s\\*.*", NomDir) ;
strcpy(szNewPath, BonDir(szHome));
BOOL fFinished = FALSE;
hSearch = FindFirstFile(szNewPath, &FileData);
if (hSearch == INVALID_HANDLE_VALUE)
{
return;
}
while (!fFinished)
{
if (((FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY )
&& FileData.cFileName[0] != '.')
{
On = 1;
Node2 = TreeView1->Items->AddChild(Node1, FileData.cFileName);
sprintf(szNewPath, "%s\\%s", NomDir,FileData.cFileName);
AddChild(Node2, szNewPath);
}
if (!FindNextFile(hSearch, &FileData))
fFinished = TRUE;
}
FindClose(hSearch);
}
void __fastcall TFormPrincipale::AddNode(TTreeNode *Node1, char *NomDir)
{
WIN32_FIND_DATA FileData;
TTreeNode *Node2;
HANDLE hSearch;
char szNewPath[MAX_PATH];
char szHome[MAX_PATH];
sprintf(szHome, "%s\\*.*", NomDir) ;
strcpy(szNewPath, BonDir(szHome));
BOOL fFinished = FALSE;
hSearch = FindFirstFile(szNewPath, &FileData);
if (hSearch == INVALID_HANDLE_VALUE)
{
return;
}
while (!fFinished)
{
if (((FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY )
&& FileData.cFileName[0] != '.')
{
Node2 = TreeView1->Items->Add(Node1, FileData.cFileName);
sprintf(szNewPath, "%s\\%s", NomDir, FileData.cFileName);
AddChild(Node2, szNewPath);
}
if (!FindNextFile(hSearch, &FileData))
fFinished = TRUE;
}
FindClose(hSearch);
} |
Partager