Visual Form Designer

The Form Designer is a WYSIWYG (What You See Is What You Get) form editor inspired by Borland C++Builder. Design forms visually, drop controls from the component palette, set properties in the Object Inspector, and watch the code generate automatically.

Two-Way Design

Changes in the designer instantly update the code, and changes in the code instantly update the designer. Your METHOD implementations are always preserved during code regeneration.

Designer Features

Control Selection

Single Selection

Click any control on the form to select it. A blue border with 8 resize handles appears:

Multi-Selection

Hold Shift and click to add/remove controls from selection, or click and drag to create a rubber band selection rectangle. All selected controls show handles simultaneously.

Copy and Paste Controls

HarbourBuilder supports full clipboard operations for controls:

ShortcutAction
Ctrl+C / Cmd+CCopy selected controls to clipboard
Ctrl+V / Cmd+VPaste controls with +16px offset
Ctrl+X / Cmd+XCut selected controls (copy + delete)
DeleteDelete selected controls

When pasting, controls are automatically offset by 16 pixels to avoid overlap with the original.

Format Menu

The Format menu provides 8 alignment and distribution modes:

CommandDescription
Align LeftAlign all selected controls to the leftmost control's left edge
Align RightAlign to the rightmost control's right edge
Align TopAlign to the topmost control's top edge
Align BottomAlign to the bottommost control's bottom edge
Center HorizontallyCenter all controls on the horizontal axis
Center VerticallyCenter all controls on the vertical axis
Space Evenly HorizontalDistribute controls evenly with equal horizontal spacing
Space Evenly VerticalDistribute controls evenly with equal vertical spacing

Real-Time Code Generation

Every action in the designer generates corresponding xBase code. For example, dropping a button generates:

@ 120, 140 BUTTON oBtn PROMPT "Button1" ;
   OF oForm SIZE 120, 32

Changing properties in the Object Inspector updates the code immediately. The two-way sync ensures your visual design and code are always in harmony.

Design Mode vs Run Mode

Forms have an FDesignMode property that controls behavior:

ModeBehavior
Design Mode (FDesignMode = .T.)Controls can be selected, moved, resized. Grid background shown. Code generation active.
Run Mode (FDesignMode = .F.)Form runs normally. Controls respond to user interaction. No code generation.

Form Properties in Designer

PropertyTypeDescription
nWidth, nHeightNumericForm dimensions in pixels
nLeft, nTopNumericPosition on screen
cTitleStringWindow title bar text
nBorderStyleNumeric0=bsSizeable, 1=bsSingle, 2=bsNone, 3=bsToolWindow
nPositionNumeric0=poDesigned, 1=poCenter, 2=poCenterScreen
nWindowStateNumeric0=wsNormal, 1=wsMinimized, 2=wsMaximized
nFormStyleNumeric0=fsNormal, 1=fsStayOnTop
lSizableLogicalAllow user to resize the window
lCenterLogicalCenter form on screen when shown

Code Examples

Simple DEFINE FORM Syntax

#include "hbbuilder.ch"

function Main()
   local oForm

   DEFINE FORM oForm TITLE "Hello World" ;
      SIZE 400, 300 FONT "Segoe UI", 10

   ACTIVATE FORM oForm CENTERED
return nil

Class-Based Approach (IDE Generated)

CLASS TForm1 FROM TForm

   METHOD CreateForm()

ENDCLASS

METHOD CreateForm() CLASS TForm1
   ::cTitle  := "Form1"
   ::nLeft   := 100
   ::nTop    := 170
   ::nWidth  := 400
   ::nHeight := 300
return nil
Both Styles Work

You can use either approach. The DEFINE FORM syntax is simpler for small apps, while the class-based approach is better for complex multi-form applications.

Tips for Efficient Form Design

  1. Use the Object Inspector — Set properties visually instead of writing code
  2. Double-click controls — Auto-generates event handlers (e.g., OnClick for buttons)
  3. Multi-select for alignment — Select multiple controls, then use Format menu to align
  4. Copy/Paste for similar controls — Design one button, paste and modify for others
  5. Use snap-to-grid — Keeps controls aligned without manual positioning
  6. Check Two-Way Tools — Switch between designer and code view to see real-time updates
  7. Save frequently — Ctrl+S saves both design data and code

On This Page

Getting Started Component Palette IDE Features Tutorials Reference Platforms Designer Features Control Selection Single Selection Multi-Selection Copy and Paste Controls Format Menu Real-Time Code Generation Design Mode vs Run Mode Form Properties in Designer Code Examples Simple DEFINE FORM Syntax Class-Based Approach (IDE Generated) Tips for Efficient Form Design