Tutorial: Hello World

In this tutorial you will build your very first HarbourBuilder application from scratch — a simple window with a button that displays a greeting. By the end, you will understand the basic project workflow: create, design, code, build, and run.

Step 1: Create a New Project

  1. Launch HarbourBuilder.
  2. Select File → New Project from the menu bar.
  3. In the New Project dialog, choose a folder (e.g. C:\Projects\HelloWorld) and enter the project name HelloWorld.
  4. Click OK. The IDE creates a HelloWorld.hbp project file and a main.prg source file with a starter template.
Project folder structure

HarbourBuilder creates a clean folder with your .hbp project file and a main.prg source. All compiled output goes into a build/ subfolder that you can safely add to .gitignore.

Step 2: Open the Form Designer

  1. In the Project Manager panel, double-click main.prg.
  2. The Form Designer opens showing an empty form titled "My First App".
  3. The Object Inspector on the left displays the form's properties.
  4. Change the cTitle property to "Hello World" and press Enter — the form title bar updates immediately.

Step 3: Add a Button

  1. Click the Standard tab in the Component Palette at the top of the IDE.
  2. Click the Button icon in the palette.
  3. Click on the form surface near the center — a button appears.
  4. In the Object Inspector, set the button's cPrompt property to "Say Hello".
  5. Optionally adjust the nTop, nLeft, nWidth, and nHeight properties to position and size the button.

Step 4: Add a Label

  1. From the Standard palette tab, click the Label icon.
  2. Click on the form above the button to place the label.
  3. Set the label's cValue property to "Click the button below!".
  4. Set nWidth to 300 so the text fits comfortably.

Step 5: Set the OnClick Event

  1. Select the button on the form (click it once).
  2. In the Object Inspector, switch to the Events tab.
  3. Double-click the OnClick event row. The IDE switches to the Code Editor and creates a handler stub.
  4. Fill in the handler so it updates the label text:
oBtn:OnClick := { || oLabel:SetValue( "Hello from HarbourBuilder!" ) }
Code blocks vs. function calls

For simple one-liners, an inline code block { || ... } is perfect. For more complex logic, call a separate static function from the block. See the Event Handling tutorial for details.

Step 6: Build and Run

  1. Press F9 (or select Run → Build & Run).
  2. Watch the Messages panel at the bottom — it shows preprocessing, compiling, linking, and launching steps.
  3. Your application window appears. Click the "Say Hello" button.
  4. The label text changes to "Hello from HarbourBuilder!".

Full Code Listing

Here is the complete main.prg for the Hello World application:

#include "hbbuilder.ch"

function Main()

   local oForm, oBtn, oLabel

   DEFINE FORM oForm TITLE "Hello World" ;
      SIZE 640, 480 FONT "Segoe UI", 10

   @ 30, 50 LABEL oLabel VALUE "Click the button below!" ;
      OF oForm SIZE 300, 24

   @ 70, 50 BUTTON oBtn PROMPT "Say Hello" ;
      OF oForm SIZE 120, 32 ;
      ACTION oLabel:SetValue( "Hello from HarbourBuilder!" )

   ACTIVATE FORM oForm CENTERED

return nil

What You Learned

Next step

Ready for more? Continue to the Working with Forms tutorial to learn how to create multi-form applications with modal dialogs and data passing between forms.

On This Page

Getting Started Component Palette IDE Features Tutorials Reference Platforms Step 1: Create a New Project Step 2: Open the Form Designer Step 3: Add a Button Step 4: Add a Label Step 5: Set the OnClick Event Step 6: Build and Run Full Code Listing What You Learned