IFormControl.SendCommand

Syntax

SendCommand(Command: String; [Argument: Variant = Null]): Variant;

Parameters

Command. Name of the command that will be send to the form.

Argument. Command argument.

Description

The SendCommand methods enables sending the command and get result of its execution.

Comments

Commands are processed in the Form.OnCommand event.

Example

Executing the example requires two forms:

The reference to the DESTINATIONFORM form must be added to the inspector of assemblies in the SOURCEFORM form. it is required to add the Public access modifier for the DESTINATIONFORM form class.

Add click handler for the Button1 with the following code:

Class SOURCEFORMForm: Form
    Button1: Button;
    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        DestForm: DESTINATIONFORMForm;
    Begin
        DestForm := New DESTINATIONFORMForm.CreateForm;
        Result := DestForm.SendCommand("Square"20);
        Self.Text := Result;
    End Sub Button1OnClick;
End Class SOURCEFORMForm;

Add the OnCommand event handler for the DESTINATIONFORM form with the following code:

Public Class DESTINATIONFORMForm: Form
    Sub DESTINATIONFORMFormOnCommand(Sender: Object; Args: ICommandEventArgs);
    Begin
        If Args.Command = "Difference" Then
            Args.Result := Args.Argument - Args.Argument;
        Elseif Args.Command = "Amount" Then
            Args.Result := Args.Argument + Args.Argument;
        Elseif Args.Command = "Square" Then
            Args.Result := Args.Argument * Args.Argument;
        End If;
    End Sub DESTINATIONFORMFormOnCommand;
End Class DESTINATIONFORMForm;

Clicking the Button1 button creates an instance of the DESTINATIONFORM form and the Square command with the 20 argument is sent to it. Command executing result will be displayed to the SOURCEFORM form title.

See also:

IFormControl