IPrxUserButtons.Add

Syntax

Add(Key: Integer; Id: String; Name: String: [Type: PrxUserButtonType = 0]): IPrxUserButtonAction;

Parameters

Key. Key of created custom button.

Id. Identifier of created custom button.

Name. Name of created custom button.

Type. Type of created custom button.

Description

The Add method adds a user method button with the specified description and type.

Example

Executing the example requires that the repository contains a regular report with the REPORT identifier and a unit with the MOD_ACTION identifier. The unit contains the following code:

Code example

The file system should contain the button image file D:\Work\Image\btn16x16.png.

Add links to the IO, Metabase, and Report system assemblies.

Sub AddUserButton;
Var
    Mb: IMetabase;
    Report: IPrxReport;
    UserBtn: IPrxUserButton;
Begin
    Mb := MetabaseClass.Active;
    Report := Mb.ItemById("REPORT").Edit As IPrxReport;
    // Create a new custom button
    UserBtn := Report.UserButtons.Add(10"UserBtn""Startup", PrxUserButtonType.Method);
    // Set up custom button
    UserBtn.ForeModule := Mb.ItemById("MOD_ACTION");
    UserBtn.Icon := New FileStream.Create("D:\Work\Image\btn16x16.png", FileOpenMode.Read, FileShare.DenyNone);
    UserBtn.IconType := "png";
    UserBtn.SmallIcon := False;
    // Set up actions
    (UserBtn.Action As IPrxUserButtonActionForeMethod).ForeMethod := "Run";
    UserBtn.BeforeAction.ForeMethod := "BeforeRun";
    UserBtn.AfterAction.ForeMethod := "AfterRun";
    UserBtn.UpdateEnable.ForeMethod := "GetEnable";
    // Save changes
    (Report As IMetabaseObject).Save;
End Sub AddUserButton;

After executing the example a new custom button is created in the regular report. Description, image, and all action handlers will be set for the button. Fore method are used as handlers.

See also:

IPrxUserButtons