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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include <dir.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Quitter1Click(TObject *Sender)
{
Form1->Close();
}
//---------------------------------------------------------------------------
AnsiString FullPath(TTreeNode * Noeud)
{
AnsiString Chemin = Noeud->Text;
TTreeNode *N1;
N1 = Noeud;
while(N1->Level>0)
{
N1 =N1->Parent;
Chemin = N1->Text + "\\" + Chemin ;
}
return Chemin;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListeLecteurs()
{
TTreeNodes *Ns;
TTreeNode * Noeud;
//TTreeNode * Noeud1;
AnsiString C;
int n1=0;
TSearchRec F;
int g;
AnsiString v;
while (n1 < TreeView1->Items->Count)
{
Noeud = TreeView1->Items->Item[n1];
v = FullPath( Noeud) + "\\";
if(!chdir (v.c_str()))
{
int done;
done = FindFirst("*",faDirectory,F);
while (!done)
{
if ((F.Attr & faDirectory) && (F.Name !=".") && F.Name != "..")
{
TreeView1->Items->AddChild (Noeud, F.Name);
}
done = FindNext(F);
}
StatusBar1->Panels->Items[0]->Text = v;
StatusBar1->Refresh();
}
else
{
StatusBar1->Panels->Items[0]->Text = v;
}
n1++;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Lirelarborescence1Click(TObject *Sender)
{
TreeView1->Items->Clear();
TTreeNode *Noeud;
TreeView1->Items->Add (NULL,(Edit1->Text ));
ListeLecteurs();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TreeView1Click(TObject *Sender)
{
if( TreeView1->Selected!=NULL)
{
StatusBar1->Panels->Items[0]->Text = IntToStr(TreeView1->Selected->AbsoluteIndex) + ": " + FullPath(TreeView1->Selected);
ListView1->Items->Clear();
TSearchRec F;
TTreeNode * Noeud;
Noeud =TreeView1->Selected;
TListItem *L;
AnsiString v;
v = FullPath( Noeud) + "\\";
if(!chdir (v.c_str()))
{
int done;
done = FindFirst("*",faAnyFile,F);
while (!done)
{
if (!(F.Attr & faDirectory))
{
L = ListView1->Items->Add();
L->Caption = FullPath(Noeud);
L->SubItems->Add( F.Name);
}
done = FindNext(F);
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Listerlesfichiers1Click(TObject *Sender)
{
int max = TreeView1->Items->Count;
TTreeNode *Noeud;
TSearchRec F;
TListItem *L;
AnsiString v;
ListView1->Items->Clear();
for (int i = 1; i< TreeView1->Items->Count ; i++)
{
Noeud = TreeView1->Items->Item[i];
v = FullPath( Noeud) + "\\";
if(!chdir (v.c_str()))
{
int done;
done = FindFirst("*",faAnyFile,F);
while (!done)
{
if (!(F.Attr & faDirectory) &&
(AnsiUpperCase(ExtractFileExt(F.Name))=="." + AnsiUpperCase(Edit2->Text)))
{
L = ListView1->Items->Add();
L->Caption = FullPath(Noeud);
L->SubItems->Add( F.Name);
}
done = FindNext(F);
}
StatusBar1->Panels->Items[0]->Text = v;
StatusBar1->Refresh();
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Icnes1Click(TObject *Sender)
{
ListView1->ViewStyle=vsIcon;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Dtails1Click(TObject *Sender)
{
ListView1->ViewStyle = vsReport;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Ouvrir1Click(TObject *Sender)
{
AnsiString Commande = """E:\\Program Files\\AutoCAD LT 98\aclt.exe """;
if (ListView1->Selected != NULL)
{
Commande = """" + ListView1->Selected->Caption + "\\"
+ ListView1->Selected->SubItems->Strings[0] + """";
int rc = (int) ShellExecute ( Application->Handle,"open",Commande.c_str(),NULL,NULL,SW_SHOWDEFAULT);
if (rc <= 32)
{
if (rc == SE_ERR_NOASSOC)
Application->MessageBox("Aucun programme n'est associé à ce fichier!","Erreur DWG-catalogue", MB_OK | MB_ICONERROR);
else
Application->MessageBox("L'application associée n'a pu être ouverte!","Erreur DWG-catalogue", MB_OK | MB_ICONERROR);
}
}
}
//--------------------------------------------------------------------------- |
Partager