NameResource: String;
The NameResource property determines an identifier of a string resource for a container.
Executing the example requires that the repository contains a resources object with the OBJ_RES identifier. There must be two icons: C:\Icon_small.ico and C:\Icon_large.ico in the file system.
Sub Main;
Var
Mb: IMetabase;
Object: IMetabaseObject;
CustomClassExtender: IMetabaseCustomExtender;
CustClasses: IMetabaseCustomClasses;
CustomClass: IMetabaseCustomClass;
Operations: IMetabaseCustomClassOperations;
Operation: IMetabaseCustomClassOperation;
CreateInfo: IMetabaseObjectCreateInfo;
Description: IMetabaseObjectDescriptor;
ImgList: IGxImageList;
ImgList32: IGxImageList;
Icon: IGxIcon;
CustomObject: IMetabaseCustomObject;
Begin
Mb := MetabaseClass.Active;
// Creation of the custom classes container
CreateInfo := Mb.CreateCreateInfo;
CreateInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUSTOM_EXTENDER;
CreateInfo.Name := "CUSTOM_EXTENDER";
CreateInfo.Permanent := True;
CreateInfo.Parent := Mb.Root;
Description := Mb.CreateObject(CreateInfo);
Object := Description.Edit;
CustomClassExtender := Object As IMetabaseCustomExtender;
ImgList := New GxImageList.Create;
ImgList.Height := 16;
Icon := New GxIcon.CreateFromFile("C:\Icon_small.ico");
ImgList.AddIcon(Icon);
CustomClassExtender.SmallImages := ImgList;
ImgList32 := New GxImageList.Create;
ImgList32.Height := 32;
Icon := New GxIcon.CreateFromFile("C:\Icon_large.ico");
ImgList32.AddIcon(Icon);
CustomClassExtender.LargeImages := ImgList32;
CustomClassExtender.IsShared := True;
CustomClassExtender.Resource := Mb.ItemById("OBJ_RES").Bind As IResourceObject;
CustomClassExtender.NameResource := "ID_CUSTOM_EXTENDER";
// Add custom class into a container
CustClasses := CustomClassExtender.Classes;
CustomClass := CustClasses.Add;
CustomClass.Description := "Own class";
CustomClass.ImageIndex := 0;
Operations := CustomClass.Operations;
Operation := Operations.Add(0);
Operation.Name := "New method";
Object.Save;
// Creation of the custom class object
CreateInfo.ClassId := CustomClass.ClassId;
CreateInfo.Name := "An object of its own class";
CreateInfo.Permanent := True;
CreateInfo.Parent := Mb.Root;
Description := Mb.CreateObject(CreateInfo);
Object := Description.Edit;
CustomObject := Object As IMetabaseCustomObject;
CustomObject.Extender := CustomClassExtender;
CustomObject.CustomClass := CustomClass;
Object.Save;
End Sub Main;
After executing this example the custom classes container that contains one class is created. An object of this class is created in the repository. An identifier of the string resource ID_CUSTOM_EXTENDER from the OBJ_RES resources will be determined for a container.
See also: