IResourceBinaries.Load

Syntax

Load(Key: Integer; Stream: IIOStream): Boolean;

Parameters

Key. Image key.

Stream. Stream.

Description

The Load method loads an image with the specified resource key to stream.

Comments

If loading is successfully completed, the method returns True, otherwise it returns False.

Example

Executing the example requires a form containing the ImageList component with the ImageList1 identifier. The component must contain an image used for icons of other form components. The form must contain connected resources containing a image with the ImgList identifier. Resources must contain two languages: Russian (default language) and English (translation language). The ImgList image must contain Russian and English language icons for form components.

Add links to the IO, Metabase system assemblies.

The procedure given as an example must be executed on occurring the OnCreate event for a form.

Sub TestFormOnCreate(Sender: Object; Args: IEventArgs);
Var
    MB: IMetabase;
    Resource: IResourceObject;
    Locales: IResourceLocales;
    Locale: IResourceLocale;
    Binares: IResourceBinaries;
    Stream: IIOStream;
    BinKey: Integer;
Begin
    // Get resources
    Resource := Self.Resources;
    // Get resource languages
    Locales := Resource.Locales;
    // Get current repository
    MB := MetabaseClass.Active;
    // Search in resources for the current repository language
    Locale := Locales.FindByKey(MB.CurrentLocale);
    // Get resource images for the current repository language
    Binares := Locale.Binaries;
    // Create a stream
    Stream := New MemoryStream.Create;
    // Get key for resource image for the current repository language
    BinKey := Binares.FindById("ImgList");
    // Load image with found key from resources
    If Binares.Load(BinKey, Stream) Then
        // Load image from the stream into the ImageList component
        ImageList1.LoadFromStream(Stream);
    End If;
End Sub TestFormOnCreate;

After executing the example icons used for form components depend on the current repository language.

See also:

IResourceBinaries