Show: Delphi C++
Display Preferences

Writing an Event Handler for the Button

From RAD Studio XE2
Jump to: navigation, search

Go Up to Getting started with IntraWeb Index

The form does not yet perform any actions when the user clicks the OK button.

For information on editing the main form, see Editing the Main Form.

You will now write an event handler that will display a greeting when the user clicks OK.

  1. Double-click the OK button on the form. An empty event handler is created in the editor window, like the one shown here:
procedure TformMain.IWButton1Click(Sender: TObject);
begin

end;
  1. Using the editor, add code to the event handler so it looks like the following:

    procedure TformMain.IWButton1Click(Sender: TObject);
    var s: string;
    begin
       s := editName.Text;
       if Length(s) = 0 then
          WebApplication.ShowMessage("Please enter your name.")
       else
       begin
          WebApplication.ShowMessage("Hello, " + s +"!");
          editName.Text := "";
       end;
    end;
    

For information about running the completed application, see Running the Completed Application.

See Also

Personal tools
Previous Versions
In other languages