[Overview][Resource strings][Constants][Types][Classes][Index] Reference for unit 'resource' (#fcl-res)

TAbstractResource

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Base abstract resource class

Declaration

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

  property LangID: TLangID; [rw]

  

The language ID of the resource

  property DataSize: LongWord; [r]

  

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

  property Version: LongWord; [rw]

  

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

  property CodePage: LongWord; [rw]

  

The code page of the resource

  property RawData: TStream; [r]

  

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;

Inheritance

TAbstractResource

  

Base abstract resource class

|

TObject

Description

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.

See also

TGenericResource

  

Generic resource class

TAcceleratorsResource

  

Accelerator table resource type

TBitmapResource

  

Bitmap resource type

TGroupCursorResource

  

Group cursor resource type

TGroupIconResource

  

Group icon resource type

TStringTableResource

  

String table resource type

TVersionResource

  

Version information resource type

TResources

  

A collection of resources

TResourceFactory

  

Factory class for resources


Documentation generated on: May 14 2021