IRibbon.LoadFromXML

Fore Syntax

LoadFromXML(Value: String);

Fore.NET Syntax

LoadFromXML(Value: String);

Parameters

Value. Character string that contains XML structure of the ribbon.

Description

The LoadFromXML method loads and creates a visual ribbon.

Comments

When this method is called, the visual module ribbon is formed on the base of passed XML structure. The images used in controls will be loaded from the resources repository.

The ribbon structure must not include system identifiers (such as, ID_APP_EXIT). Such identifiers will be replaced with automatically generated ones.

Example

Executing the example requires a form, the Ribbon component named Ribbon1 on it. There is a document with the RibbonXML identifier and the Resources object with the RibbonResource identifier in the repository. The XML structure of the ribbon is saved in the document, the images that are used by the controls of the ribbon are stored in the resource. The following procedure is set as a handler of the OnCreate event of the form.

Sub TestFormOnCreate(Sender: Object; Args: IEventArgs);
Var
    MB: IMetabase;
    Doc: IDocument;
    Res: IResourceObject;
    MStream: IMemoryStream;
    TxtRead: ITextReader;
    RibbonXML: String;
Begin
    MB := MetabaseClass.Active;
    Doc := MB.ItemById("RibbonXML").Bind As IDocument;
    Res := MB.ItemById("RibbonResource").Bind As IResourceObject;
    MStream := New MemoryStream.Create;
    Doc.SaveToStream(MStream);
    TxtRead := New TextReader.Create(MStream);
    TxtRead.Encoding := CodePage.UTF8;
    RibbonXML := TxtRead.ReadToEnd;
    Ribbon1.Resources := Res;
    Ribbon1.LoadFromXML(RibbonXML);
End Sub TestFormOnCreate;

When the event occurs, the ribbon is loaded and set up in the Ribbon1 component.

See also:

IRibbon