Saving in TThumbnailList component from TMS (500 points)

I have a component called ThumbnailList from TMS which displayed all pictures in a folder as thumbnails.  It takes a while to display every time so I would like to dot his once only and then save into a file.  How can I do this?

I am using Delphi6. I am giving the maximum 500 points for this.  Many thanks for your help.
rincewind666Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ben-thompsonCommented:
I don't think there is anything like that in the component.
Either you could write the thumbnails to file, like XP does with thumbs.db or try ReadComponentResFile and WriteComponentResFile. This will save all of the component's properties, including the pictures and their paths to a res file, though I've never done it.
//==============================================================================
procedure SaveThumbsToFile(Thumbs : TThumbnailList; const FN : string);
begin
  WriteComponentResFile(FN, Thumbs);
end;
 
//==============================================================================
function  LoadThumbsFromFile(const FN : string) : TThumbnailList;
begin
    Result := ReadComponentResFile(FN, nil) as TThumbnailList;
end;

Open in new window

0
rincewind666Author Commented:
I am getting the following error when I try to load it again (however something is being saved):
class TThumbnailList not found

Sorry.  I'm a beginner in Delphi. I am using the following code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ThumbnailList, SkinBoxCtrls, spfilectrl, SkinCtrls,
  SkinData, DynamicSkinForm, AdvPicture;

type
  TForm1 = class(TForm)
    spDynamicSkinForm1: TspDynamicSkinForm;
    spSkinData1: TspSkinData;
    PathLabel: TspSkinLabel;
    spSkinPanel1: TspSkinPanel;
    DriveComboBox1: TspSkinDriveComboBox;
    dlb: TspSkinDirectoryListBox;
    CreateThumbnailsBtn: TspSkinButton;
    Cooler: TspCompressedStoredSkin;
    tl: TThumbnailList;
    LoadThumbnailsBtn: TspSkinButton;
    SaveThumbnailsBtn: TspSkinButton;
    procedure CreateThumbnailsBtnClick(Sender: TObject);
    procedure tlClick(Sender: TObject);
    procedure LoadThumbnailsBtnClick(Sender: TObject);
    procedure SaveThumbnailsBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
      lastDir: string;

implementation

uses Unit2;

{$R *.dfm}

//==============================================================================
procedure SaveThumbsToFile(Thumbs : TThumbnailList; const FN : string);
begin
  WriteComponentResFile(FN, Thumbs);
end;
 
//==============================================================================
function  LoadThumbsFromFile(const FN : string) : TThumbnailList;
begin
    Result := ReadComponentResFile(FN, nil) as TThumbnailList;
end;


procedure TForm1.CreateThumbnailsBtnClick(Sender: TObject);
begin
 if lastDir = dlb.Directory then exit;

  lastDir := dlb.Directory;

  tl.BeginUpdate;
  try
    tl.ShowFolder(dlb.Directory+'\*.*');
  finally
    tl.EndUpdate;
  end;
end;

procedure TForm1.tlClick(Sender: TObject);
begin
  if tl.ItemIndex >= 0 then
  begin
  PathLabel.Caption := tl.Thumbnails.Items[tl.ItemIndex].FileName;
  Application.CreateForm(TPictureForm, PictureForm);
  PictureForm.Show;
  end;


end;

procedure TForm1.LoadThumbnailsBtnClick(Sender: TObject);
begin
LoadThumbsFromFile('backgrounds\xxx');
end;

procedure TForm1.SaveThumbnailsBtnClick(Sender: TObject);
begin
SaveThumbsToFile(tl,'xxx');
end;

end.
0
ben-thompsonCommented:
Try changing the LoadThumbnailsBtnClick procedure as below.
procedure TForm1.LoadThumbnailsBtnClick(Sender: TObject);
begin
  ReadComponentResFile('backgrounds\xxx', FN);
end;

Open in new window

0
ben-thompsonCommented:
Sorry, ignore last post, it contained a mistake
procedure TForm1.LoadThumbnailsBtnClick(Sender: TObject);
begin
  ReadComponentResFile('backgrounds\xxx', tl);
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rincewind666Author Commented:
Yes.  It now works perfectly.  Many thanks for your kind help  Well worth 500 points - you are brilliant!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.