IGxImageList.LoadFromFile

Syntax

LoadFromFile(Value: String; [Transparent: IGxColor = Null]);

Parameters

Value. Parameter that determines the line specifying the path to the file, which will be loaded to the collection.

Transparent. Parameter that determines the color that is used as a transparent one.

Description

The LoadFromFile method loads images to the collection from the file, which path and name are passed by the Value parameter.

Example

Executing the example requires that the file system contains two icons: C:\Icon_small.bmp and C:\Icon_large.bmp. Add links to the Metabase, Drawing, Fore, Io system assemblies in the unit.

Sub UserProc;
Var
    Mb: IMetabase;
    Object: IMetabaseObject;
    CustomClassExtender: IMetabaseCustomExtender;
    CustClasses: IMetabaseCustomClasses;
    CustomClass: IMetabaseCustomClass;
    Description: IMetabaseObjectDescriptor;
    ImgList: IGxImageList;
    ImgList32: IGxImageList;
Begin
    Mb := MetabaseClass.Active;
    // Determine container of custom classes
    Description := Mb.SpecialObject(MetabaseSpecialObject.CustomExtender);
    Object := Description.Edit;
    CustomClassExtender := Object As IMetabaseCustomExtender;
    // Create a collection of images
    ImgList := New GxImageList.Create;
    ImgList.Height := 16;
    ImgList.LoadFromFile("C:\Icon_small.bmp", GxColor.FromKnownColor(GxKnownColor.White));
    CustomClassExtender.SmallImages := ImgList;
    ImgList32 := New GxImageList.Create;
    ImgList32.Height := 32;
    ImgList32.LoadFromFile("C:\Icon_large.bmp", GxColor.FromKnownColor(GxKnownColor.White));
    CustomClassExtender.LargeImages := ImgList32;
    CustomClassExtender.IsShared := True;
    // Add a custom class to the container
    CustClasses := CustomClassExtender.Classes;
    CustomClass := CustClasses.Add;
    CustomClass.Name := "My class";
    CustomClass.Description := "Custom class";
    CustomClass.ImageIndex := 0;
    Object.Save;
End Sub UserProc;

After executing the example the custom classes container including a class named My Class will be created. The source for a big icon will be the file C:\Icon_large.bmp, for a little icon - C:\Icon_small.bmp.

See also:

IGxImageList