Contains group resource classes

This unit contains and , two classes used for resources of type RT_GROUP_ICON and RT_GROUP_CURSOR.

The former is an abstract resource class which is implemented by TGroupIconResource and TGroupCursorResource, and the latter is a TCachedDataStream descendant used to provide .ico/.cur like streams for resource classes mentioned earlier.

This unit shouldn't be of interest for the user, who should look at documentation for and units instead.

Abstract common class for group icon and group cursor classes

This class provides common functionalities that are extended by TGroupIconResource and TGroupCursorResource.

Resources of type RT_GROUP_ICON and RT_GROUP_CURSOR represent a .ico or .cur file, respectively. However, data isn't contained in a single resource, but it's scattered over several different resources. That is, a .ico file contains an icon, which is made of several different images (for different sizes and color depth); when it is represented as a resource, however, the RT_GROUP_ICON resource only contains information about the single images, which are contained each in a different resource of type RT_ICON. The single resources are pretty unuseful alone, since they only consist of raw image data: they must be accessed in the contest of the RT_GROUP_ICON resource, which provides information about them.

TGroupIconResource and TGroupCursorResource provide a way to handle resources of these types as if they were .ico or .cur files. This class implements common functionalities, since icons and cursors are very similar.

An object of this class should never be directly instantiated: use a descendant class instead.
TGroupIconResource TGroupCursorResource
Sets a custom stream as the underlying stream for ItemData

This method allows the user to use a custom stream as the underlying stream for ItemData. This is useful when you want a TGroupIconResource or TGroupCursorResource to be created from a ico or cur file for which you have a stream.

Sample code

This code creates a resource containing an icon

var aName : TResourceDesc; aRes : TGroupIconResource; aFile : TFileStream; Resources : TResources; begin Resources:=TResources.Create; aName:=TResourceDesc.Create('MAINICON'); aRes:=TGroupIconResource.Create(nil,aName); //type is always RT_GROUP_ICON aName.Free; //not needed anymore aFile:=TFileStream.Create('mainicon.ico',fmOpenRead or fmShareDenyNone); aRes.SetCustomItemDataStream(aFile); Resources.Add(aRes); Resources.WriteToFile('myresource.res'); Resources.Free; //it destroys aRes as well. aFile.Free; end;
TGroupIconResource TGroupCursorResource TAbstractResource.UpdateRawData
The custom stream to use as the underlying ItemData stream Resource data as an ICO/CUR stream

This property gives access to resource data in a (ICO or CUR) file-like stream, unlike RawData.

The exact format of the stream (ico or cur) is determined by the descendant class of that is used.

ItemData does not create a copy of RawData so memory usage is generally kept limited.

You can also set a custom stream as the underlying stream for ItemData via SetCustomItemDataStream, much like SetCustomRawDataStream does for RawData. This is useful when you want a TGroupIconResource or TGroupCursorResource to be created from a ico or cur file for which you have a stream.

If you need to access RawData after you modified ItemData, be sure to call UpdateRawData first. This isn't needed however when resource is written to a stream, since TResources takes care of it.
TGroupIconResource TGroupCursorResource TAbstractResource.RawData TAbstractResource.UpdateRawData
Cached stream for group classes

This class is used by descendants to provide an .ico/.cur like stream.

Unlike TCachedResourceDataStream, which provides a stream-like interface over a portion of another stream, this class lets multiple stream to be seen as one: this way, several RT_ICON or RT_CURSOR resources can appear like a single .ico or .cur file.

TGroupIconResource TGroupCursorResource TCachedDataStream TCachedResourceDataStream