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
   | void __fastcall TMainForm::LoadImageList()
{
        Graphics::TBitmap *Pimage = new Graphics::TBitmap();
        TJPEGImage *jpg = new TJPEGImage();
        TListItem *pItem;
 
        TImage *TI = new TImage(this);
        TI->Height = 80;
        TI->Width = 80;
 
        ImageList->Clear();
        ListView->Clear();
 
        for(unsigned int i=0; i<VCheminImageFic.size(); i++)
        {
 
                // Chargement des images à partir d'un vecteur contenant les chemins des images
                AnsiString t = VCheminImageFic.at(i);
                jpg->LoadFromFile(t);
                TI->Canvas->StretchDraw(Rect(0,0,80,80),jpg);
                Pimage = TI->Picture->Bitmap;
                ImageList->Add(Pimage,NULL);
 
               // Affichage du texte en dessous de l'icone
                pItem = ListView->Items->Add();
                pItem->Caption = "Image" + IntToStr(i);
                pItem->ImageIndex = i;
        }
 
        if(VCheminImageFic.size() != 0)
                ListView->Enabled = true;
        else
                ListView->Enabled = false;
} | 
Partager