AddByType([Type: PrxUserButtonType = 0]): IPrxUserButtonAction;
Type. Type of created custom button.
The AddByType method creates a custom button with the specified type.
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:
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 custom button
UserBtn := Report.UserButtons.AddByType(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. A description will be created for the button, image, and all action handlers will be set. Fore methods are used as handlers.
See also: