Martijn
Martijn

Reputation: 5673

Create TImageList by specifying paths only

In Delphi 2007, images are loaded in a TImageList at design time. This introduces the following problem:

Is there any way (component, compile script, ...) to perform steps 2 and 3 automatically, that is, specify only paths of graphics at design time, creating a dependence on the actual graphic files?

Upvotes: 1

Views: 354

Answers (3)

Rohit Gupta
Rohit Gupta

Reputation: 4185

I load the images into the TImagelist at runtime. For this very reason, I do not assign any images at design time. They are all added as a resource to the exe and I load them at runtime from there. This also means that the images can be changed without recompiling the exe.

Upvotes: 0

Jeroen Wiert Pluimers
Jeroen Wiert Pluimers

Reputation: 24523

You could create a descendant of TImageList and add that kind of logic there.

Since components referring to images inside a TImageList do that by index, it would be easiest to have your descendant to have a ImagePaths property of type TStrings that is formatted like this:

#=Filename

And maybe add a property BasePath of type string as well.

Then upon loading that component, it could automagically reload those images in memory.

You could even make it a design-time expert which loads the images in the designer.

--jeroen

Upvotes: 2

Marco van de Voort
Marco van de Voort

Reputation: 26371

Classes are never fully compiletime. Designtime classes are streamed from resources too.

Upvotes: 1

Related Questions