I wrote using code found to network, a small example that collects images on an ImageList component.
I found that the WriteComponentResFile function allows me to save the component status but I did not understand how it should be restored using the ReadComponentResFile function that does not seem to work.
Thank you
- Code: Select all
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "jpeg.hpp"
int ni=0;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
for(int i=0;i<FileListBox1->Items->Count;i++)
{
Graphics::TBitmap *bmp = new Graphics::TBitmap;
TJPEGImage *jpeg = new TJPEGImage;
jpeg->LoadFromFile(FileListBox1->Items->Strings[i]);
bmp->Assign(jpeg);
TListItem *pItem;
ImageList1->Add(bmp, NULL);
pItem = ListView1->Items->Add();
pItem->Caption = GetCurrentDir() + "\\" + FileListBox1->Items->Strings[i];
pItem->ImageIndex = ni++;
delete bmp;
delete jpeg;
}
WriteComponentResFile("ImageList.dat", ImageList1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ImageList1->Clear();
ListView1->Items->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
ReadComponentResFile("ImageList.dat", ImageList1);
}
//---------------------------------------------------------------------------