RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Building a VCL Forms Hello World Application

The Windows Forms Hello World application demonstrates the essential steps for creating a VCL Forms application. The application uses a VCL Form, a control, an event, and displays a dialog in response to a user action. 

Creating the Hello World application consists of the following steps:

  1. Create a VCL.NET Form with a button control.
  2. Write the code to display "Hello World" when the button is clicked.
  3. Run the application.

To create a VCL Form

  1. Choose FileNewOtherDelphi for .NET ProjectsVCL Forms Application. The VCL Forms Designer displays.
  2. Click the Design tab to display the form view.
  3. From the Standard category of the Tool Palette, place a TButton component on the form.

To display the "Hello World" string

  1. Select Button1 on the form.
  2. In the Object Inspector, double-click the OnClick event handler on the Events tab. The Code Editor appears, with the cursor in the TForm1.Button1Click event handler block.
  3. Place the cursor before the begin reserved word and then press Return. This creates a new line above the code block.
  4. Insert the cursor on the new line created, and type the following variable declaration:

var s: string;

  1. Insert the cursor within the code block, and type the following code:

s:= 'Hello World!';
ShowMessage(s);
To run the "Hello World" application

  1. Save your project files.
  2. Choose RunRun to build and run the application. The form displays with a button called Button1.
  3. Click Button1. A dialog box displays the message "Hello World!".
  4. Click OK to close the message dialog.
  5. Close the VCL form to return to the IDE.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!