[Overview][Resource strings][Constants][Types][Classes][Index] |
[Properties (by Name)] [Methods (by Name)] [Events (by Name)]
Base abstract resource class
Source position: resource.pp line 130
type TAbstractResource = class |
||
protected |
||
procedure SetDescOwner(); |
|
Sets this resource as the owner of the given TResourceDesc |
procedure SetOwnerList(); virtual; |
|
Protected method to let a resource list set itself as the owner of the resource |
procedure SetChildOwner(); |
|
Protected method to let a resource set itself as the owner of a sub-resource |
function GetType; virtual; abstract; |
|
Returns the type of the resource |
function GetName; virtual; abstract; |
|
Returns the name of the resource |
function ChangeDescTypeAllowed(); virtual; abstract; |
|
Reports whether changing the type of resource type or name is allowed |
function ChangeDescValueAllowed(); virtual; abstract; |
|
Reports whether changing the value of resource type or name is allowed |
procedure NotifyResourcesLoaded; virtual; abstract; |
|
Tells the resource that all resources have been loaded |
constructor Create(); |
|
Creates a new resource |
public |
||
destructor Destroy; override; |
|
Destroys the object |
function CompareContents(); virtual; |
|
Compares the contents of the resource to the contents of another one |
procedure UpdateRawData; virtual; abstract; |
|
Updates RawData stream. |
procedure SetCustomRawDataStream(); |
|
Sets a custom stream as the underlying stream for RawData |
property _Type: TResourceDesc; [r] |
|
The type of the resource |
property Name: TResourceDesc; [r] |
|
The name of the resource |
|
The language ID of the resource |
|
|
The size of resource raw data |
|
property HeaderSize: LongWord; [r] |
|
The size of resource header |
property DataVersion: LongWord; [rw] |
|
The version of the resource data |
property MemoryFlags: Word; [rw] |
|
The memory flags of the resource |
|
A user defined version number |
|
property Characteristics: LongWord; [rw] |
|
A user defined piece of data |
property DataOffset: LongWord; [r] |
|
The offset of resource data from the beginning of the stream |
|
The code page of the resource |
|
|
The raw resource data stream |
|
property CacheData: Boolean; [rw] |
|
Controls the copy-on-write behaviour of the resource |
property OwnerList: TResources; [r] |
|
The resource list that owns this resource |
property Owner: TAbstractResource; [r] |
|
The owner of this resource |
end; |
|
Base abstract resource class |
|
| | ||
TObject |
This is the base class that represents a resource.
A resource is identified by its type, name and language ID even if some file formats or operating systems don't consider the latter.
There are also additional properties that aren't always present in all file formats, so their values aren't always meaningful: however, they can be used to display detailed information when possible.
Every resource has a RawData stream that holds resource data. This stream uses a copy-on-write mechanism: if the resource has been read from a stream or file, RawData redirects read operations to the original stream. This is particularly useful when a resource file must be converted from a format to another, or when more resource files must be merged, since (potentially large) resource data is directly copied from the original to the destination stream without the need of allocating a lot of memory.
When resource data is encoded in a resource-specific format, RawData can be uncomfortable: it's often better to use a more specialized descendant class that provides additional properties and methods.
Resources cannot be read or written alone from/to a stream: they need to be contained in a TResources object, which represents an abstract view of a resource file.
Usually each descendant registers itself with TResourceFactory class in the initialization section of the unit in which it is implemented: this way TResourceFactory class can know which class to use to instantiate a resource of a given type.
Remark: | An object of this class should never be directly instantiated: use a descendant class instead. |
|
Generic resource class |
|
|
Accelerator table resource type |
|
|
Bitmap resource type |
|
|
Group cursor resource type |
|
|
Group icon resource type |
|
|
String table resource type |
|
|
Version information resource type |
|
|
A collection of resources |
|
|
Factory class for resources |