IFormControl.SendCommand

Syntax

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

Parameters

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

Argument. Command argument.

Description

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

Comments

Commands are processed in the Form.OnCommand event.

Example

Executing the example requires two forms:

Add a link to the DESTINATIONFORM form in the assembly inspector in the SOURCEFORM form. Add the Public access modifier for the DESTINATIONFORM form class.

Add a click handler for the Button1 button 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