EtheaDev/IconFontsImageList

How to use TIconFontsImageCollection + TVirtualImageList

SoyYako opened this issue · 3 comments

Any example, demo or wiki?

The Demo now uses TIconFontsImageCollection into a Datamodule shared with all forms.
If you compile with 10.3 or 10.4 then the Demo uses a VirtualImageList created at runtime (look into .pas code), but if you want, simply drop a VirtualImageList on the UMain Form, attach ImageCollection to the IconFontsImageCollection and use it instead of TIconFontsVirtualImageList...

Ok....
What is your recommendation for development?

The TIconFontsImageCollection AND/OR TVirtualImageList in the DataModule and the IconFonsInmageList in the MainForm of the application?

I mean, I read that for DPI sizing to be done correctly, the IconFonsInmageList had to be in a Form, since the DataModule is not a visual container.

This still stands or is there a paradigm shift?

As mentioned in readme and wiki:
Very important notice:
TVirtualImageList (available from D10.3) and TIconFontsVirtualImageList both use images from TIconFontsImageCollection. An important difference is that TVirtualImageList may use and create only a subset of the images in the collection, whereas TIconFontsVirtualImageList creates all images of the collection everytime it is needed (e,g. DPI change), which is slower and consumes more memory.
We advise that TIconFontsVirtualImageList should be used only for versions of Delphi before 10.3. For recent versions of Delphi the recommended combination should be TIconFontsImageCollection + TVirtualImageList. Don't forget also the importance of PreserveItems when you have a large ImageCollection with many linked Actions. Without setting this property to "True", everytime you add or remove an icon in the collection, you have to check and change the ImageIndex of all the Actions.

I suggest:
One datamodule (shared) with TIconFontsImageCollection (created at startup).
On every Form, one native TVirtualImageList for every size needed: if you have, for example a toolbar of size 16 and buttons of size 24 you can define two TVirtualImageList of sizes 16 and 24.