[debutant]supprimer image
salut,
j'essaie de faire une visionneuse,
quand je la selctionne l'image s'affiche bien, mais je n'arrives pas faire en sorte que rien ne soit affiché losrque je supprime l'image...
si quelqu'un pourrait essayer de m'eclairer...
voila une partie du code :
Code:
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
|
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ListeFichiers = new TStringList ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender) //bouton ajouter
{
OpenDialog1->Title = "ouverture de fichier";
if (OpenDialog1->Execute())
{
int index;
ListeFichiers->Sort(); //find ne marche que sur les listes triées
if (ListeFichiers->Find((OpenDialog1->Files)->Strings[0],index))
{
Application->MessageBox("Ce fichier existe deja", NULL, MB_OKCANCEL) ;
}
else
{
ListeFichiers->Add((OpenDialog1->Files)->Strings[0]);
CreationListe();
}
}
}
//---------------------------------------------------------------------------
void TForm1::CreationListe() //sert a remplir liste fichier
{
for (int i = ListBox1->Items->Count - 1; i >= 0 ; i--)
{ //retire les elements de listbox
ListBox1->Items->Delete(i);
}
int ImagePosition = 10;
for (int i=0; i<ListeFichiers->Count; i++)
{ //mets les elements de liste fichiers dans la listbox1
AnsiString Extension = ExtractFileExt(ListeFichiers->Strings[i]).LowerCase();
TImage *Image = Image1;
Image->Top = ImagePosition;
Image->Left = 10;
if (Extension==".bmp") //si c'est un .bmp
{
Image->Picture->LoadFromFile(ListeFichiers->Strings[i]);
}
ListBox1->Items->Add(ExtractFileName(ListeFichiers->Strings[i])); //ajoute nom dans listbox1
}
}
void __fastcall TForm1::Button2Click(TObject *Sender) //bouton supprimer
{
for (int i = ListBox1->Items->Count - 1; i >= 0 ; i--)
{
if (ListBox1->Selected[i])
{
ListeFichiers->Delete(i);
ListBox1->Items->Delete(i);
Label1->Caption="";
ListBox2->Items->Delete(i);// vider listbox2
Image1->Refresh();
}
}
} |
les images sont affichés dans liste 2