void __fastcall tform1::formcreate (tobject *sender)
{
Currentdir=getcurrentdir ();
Updatetreeview ();
Updatelistview ();
}
//---------------------------------------------------------------------------
void __fastcall Tform1::updatetreeview ()
{
Ttreenode *rnode,*mnode;
Treeview1->items->clear ();
Rnode=treeview1->items->add (treeview1->selected, "My Computer");
rnode->imageindex=1;
rnode->selectedindex=1;
Mnode=treeview1->items->addchild (Rnode, "A:");
mnode->imageindex=2;
mnode->selectedindex=2;
Adddirectory ("A:", Mnode);
for (int i=1;i<drivecombobox1->items->count;i++)
{
Mnode=treeview1->items->addchild (rnode,ansistring (char (' B ' +i)) + ":");
mnode->imageindex=3;
mnode->selectedindex=3;
Adddirectory (ansistring (char (' B ' +i)) + ":", Mnode);
}
}
//------------------------------------------------------------------------
void Tform1::adddirectory (ansistring path,ttreenode *fnode)
{
Tsearchrec SR;
Ttreenode *mnode;
if (FindFirst (path+ "\\*.*", FADIRECTORY,SR) ==0)
{
if (Sr. Attr==fadirectory)
{
if (Sr. Name!= "." &&SR. Name!= "..")
{
Mnode=treeview1->items->addchild (FNODE,SR. Name);
mnode->imageindex=0;
mnode->selectedindex=4;
Adddirectory (path+ "\" +SR). Name,mnode);
}
}
}
while (FindNext (SR) ==0)
{
if (Sr. Attr==fadirectory)
{
if (Sr. Name!= "." &&SR. Name!= "..")
{
Mnode=treeview1->items->addchild (FNODE,SR. Name);
mnode->imageindex=0;
mnode->selectedindex=4;
Adddirectory (path+ "\" +SR). Name,mnode);
}
}
}
FindClose (SR);
}
//--------------------------------------------------------------------
void __fastcall tform1::treeview1changing (tobject *sender, Ttreenode *node, bool &allowchange)
{
screen->cursor=crhourglass;
Tsearchrec SR;
Ttreenode *nodetmp=node;
Ansistring dirname,dirtmp;
dirname=node->text;
for (int i=node->level;i>1;i--)
{
nodetmp=nodetmp->parent;
dirtmp=nodetmp->text;
if (Dirtmp.substring (Dirtmp.length (), 1)!= "\")
dirtmp+= "\";
Dirname.insert (dirtmp,0);
}
if (Dirname.substring (Dirname.length (), 1)!= "\")
dirname+= "\";
for (int j=0;j<node->count;j++)
{
if (node->item[j]->count==0);
{
if (FindFirst (dirname+node->item[j]->text+ "\\*.*", Faanyfile, sr) = 0)
{
Todo
{
node->item[j]->imageindex=5;
node->item[j]->selectedindex=4;
if (Sr. Attr&fadirectory) &&sr. Name!= "." &&SR. Name!= "..")
{
node->item[j]->imageindex=0;
node->item[j]->selectedindex=4;
Treeview1->items->addchild (NODE->ITEM[J],SR. Name);
}
}
while (FindNext (SR) ==0);
FindClose (SR);
}
}
}
screen->cursor=crdefault;
}