Bernhard
Bernhard

Reputation: 61

Delphi IDE changing imagelist in inherited DFM files

When opening a form which contains an inherited TImageList in Delphi (2010 in this case, but it may do it for other versions), the IDE invariably (I can't find any rhyme or rhythm to it) adds the image data again to the inherited form. This then increases the size of the executable. any one know why, and how I can stop it happening? I repeat, the image has not changed.

Upvotes: 6

Views: 1648

Answers (4)

Jamie
Jamie

Reputation: 3172

What I do is put the imagelist on a data module and then add it to the forms uses clause. The form designer will be able to see the image list

Upvotes: 5

Allen Bauer
Allen Bauer

Reputation: 16862

This isn't a "solution" to the problem, but more an explanation of what is going on. The image data for a given image list is stored as a binary blob of data. This blob of data is obtained from the underlying IMAGELIST implementation from the comctl32.dll.

What is likely happening is that for some reason the Windows implementation down in comctl32.dll is streaming the image data differently between the "ancestor" instance and the "descendant" instance. To Windows, there is no relationship between these two instances.

The way form-inheritance works is that it does a property-by-property comparison between the "descendant" and the "ancestor" while streaming to determine if a given property should be written to the form. Because the image data is an opaque blob of goo, all we can do is a byte-for-byte comparison between what the TImageList instance on the ancestor writes and what the TImageList instance on the descendant writes. If only one byte were different, the streaming system has no choice but to write the data from the descendant instance on the presumption that something changed. For instance (and I don't really know the details since it is opaque), if the blob of goo contained a timestamp, it is conceivable that each time it is written the data would be different.

Upvotes: 4

Mason Wheeler
Mason Wheeler

Reputation: 84550

This is a known issue with TImageList, and there's not much you can do about it except to keep deleting the garbage data again. (BeyondCompare can be very useful here, especially in conjunction with source control.) If you want to see it fixed, please vote for the QC report on it.

Upvotes: 5

David Heffernan
David Heffernan

Reputation: 612993

My recommendation: never keep images in .dfm files. Always put them in resource files and regain control of your app.

Upvotes: 2

Related Questions