Samples & Learning Path

FiveWin ships with over 1,000 sample programs organized in the samples/ directory. This guide maps them into a structured learning path so you can progress from your first "Hello World" to advanced AI-powered applications.

Learning Path Overview

The diagram below shows the recommended progression. Start with the tutorials in start/, branch out through intermediate topics that interest you, then tackle the advanced folders when you are comfortable with the fundamentals.

flowchart TD START["Beginner
start/ (8 tutorials)"] DB["database/ (19)
Database Operations"] DATA["data/ (16)
TDatabase / TDataRow"] MENUS["menus/ (14)
All Menu Types"] REPORT["report/ (41)
Printing & PDF"] GFX["graphics/ (28)
GDI+, Charts, Images"] MAIL["mail/ (5)
SMTP, POP3, Outlook"] OLE["ole/ (8)
Word & Excel Automation"] TREES["trees/ (5)
TreeView Examples"] COMM["comm/ (10)
Serial Communications"] UNI["unicode/ (2)
Unicode Support"] AI["ai/ (47)
OpenAI, Ollama, Gemini..."] WEB["web/ (39)
WebView2, HTTP, REST"] SYS["system/ (41)
Registry, Services, DLLs"] FIVEUI["FiveUI/ (17)
Visual Forms Designer"] MISC["misc/ (467)
All FWH Features"] TEST["test/ (317)
Test Suite"] BIG["bigexe/ (16)
Large Applications"] START --> DB START --> MENUS START --> DATA DB --> REPORT DB --> OLE MENUS --> GFX DATA --> MAIL DATA --> TREES DATA --> COMM DATA --> UNI REPORT --> MISC GFX --> AI GFX --> WEB OLE --> SYS MISC --> TEST MISC --> FIVEUI MISC --> BIG AI --> BIG WEB --> BIG style START fill:#238636,color:#fff style DB fill:#1f6feb,color:#fff style DATA fill:#1f6feb,color:#fff style MENUS fill:#1f6feb,color:#fff style REPORT fill:#1f6feb,color:#fff style GFX fill:#1f6feb,color:#fff style MAIL fill:#1f6feb,color:#fff style OLE fill:#1f6feb,color:#fff style TREES fill:#1f6feb,color:#fff style COMM fill:#1f6feb,color:#fff style UNI fill:#1f6feb,color:#fff style AI fill:#da3633,color:#fff style WEB fill:#da3633,color:#fff style SYS fill:#da3633,color:#fff style FIVEUI fill:#da3633,color:#fff style MISC fill:#da3633,color:#fff style TEST fill:#da3633,color:#fff style BIG fill:#da3633,color:#fff

Green = Beginner   Blue = Intermediate   Red = Advanced

First Steps: Your First 5 Samples

If you are completely new to FiveWin, work through these five samples in order. Each one builds on what you learned in the previous one:

#FileWhat You Learn
1 start/tutor01.prg Hello WorldMsgInfo(), the simplest FWH program
2 start/tutor02.prg WindowsDEFINE WINDOW, ACTIVATE WINDOW
3 start/tutor03.prg DialogsDEFINE DIALOG, SAY/GET controls
4 start/tutor04.prg Buttons & Actions — button creation, ACTION clauses, event handling
5 start/tutor05.prg MenusDEFINE MENU, MENUITEM, accelerator keys

After these five, continue with tutor06.prg (databases), tutor07.prg (advanced dialogs), and tutor08.prg (putting it all together).

How to Build Samples

The samples/ directory contains several build scripts. The recommended approach for new projects:

cd c:\fwteam\samples

REM Build a sample with Borland C++ (32-bit, most common):
buildh.bat start\tutor01

REM Build with MSVC 64-bit:
buildh64.bat start\tutor01

REM The universal build script (auto-detects compiler):
build_new.bat start\tutor01

Each build script compiles the .prg file with Harbour, then compiles and links the resulting C code with the chosen compiler. See the Build System page for full details.

Beginner: start/ (8 samples)

The tutorial series walks you through every fundamental FiveWin concept, one file at a time. Each .prg file is short (under 50 lines) and heavily commented.

FileTopicKey Concepts
tutor01.prgHello WorldMsgInfo(), #include "FiveWin.ch"
tutor02.prgWindowsDEFINE WINDOW, ACTIVATE WINDOW, SIZE, TITLE
tutor03.prgDialogsDEFINE DIALOG, SAY, GET, ACTIVATE DIALOG
tutor04.prgButtons@ ... BUTTON, ACTION clause, CANCEL
tutor05.prgMenusDEFINE MENU, MENUITEM, SEPARATOR, SET MENU
tutor06.prgDatabasesUSE, BROWSE, DBF access from FWH
tutor07.prgAdvanced DialogsMultiple controls, bValid, bWhen
tutor08.prgComplete AppWindow + menu + dialog + database together

Intermediate Samples

database/ (19 samples)

Database operations including DBF browse, indexed searching, SQL queries via ADO/ODBC, and TXBrowse grid integration. Start with the basic DBF examples before moving to SQL.

Key FilesDescription
dbfbrowse.prgBasic DBF browsing with TXBrowse
sql*.prgSQL database connections and queries
xbrowse*.prgAdvanced XBrowse with database sources
ui/xbrowse/xbrml250.prgMulti-line XBrowse cell + LimitText max length (wrap, Ctrl+Enter, RTrim)

data/ (16 samples)

The TDatabase and TDataRow classes provide a higher-level abstraction over raw DBF operations. Data binding, calculated fields, and record navigation.

menus/ (14 samples)

All menu types: pull-down menus, popup/context menus, ribbon bars, system tray menus. Covers dynamic menu creation, bitmap menus, and owner-draw menus.

report/ (41 samples)

Printing and report generation with TPrinter and TReport. Includes PDF export, multi-column layouts, barcodes, charts in reports, and print preview.

graphics/ (28 samples)

GDI+ drawing, chart creation, bitmap manipulation, image loading/saving, alpha blending, and gradient fills. Demonstrates the Graphics, Pen, Brush, and GDIBmp classes.

mail/ (5 samples)

Email sending via SMTP, receiving via POP3, and Outlook integration through OLE automation.

ole/ (8 samples)

OLE Automation examples for Microsoft Word, Excel, and other COM applications. Create documents, fill spreadsheets, and control Office applications programmatically.

trees/ (5 samples)

TTreeView control examples: building tree structures, drag-and-drop between trees, XML-based tree loading, and custom node rendering.

comm/ (10 samples)

Serial port communications, modem control, barcode scanner integration, and hardware device communication.

unicode/ (2 samples)

Unicode string handling, multi-script text display, and UTF-8/UTF-16 conversion. Use FW_SetUnicode( .T. ) to enable Unicode mode globally.

Advanced Samples

ai/ (47 samples)

The newest and most exciting area of FiveWin. Integrations with multiple AI providers and even a pure-Harbour neural network implementation.

Key FilesDescription
openai*.prgOpenAI GPT integration via TOpenAI class
opencode1.prg, opencode2.prgTOpenCode (Zen free models): 3 concurrent agents; WebView2 project-agent chat
ollama*.prgLocal LLM via Ollama REST API
gemini*.prgGoogle Gemini AI integration
grok*.prgxAI Grok integration
deepseek*.prgDeepSeek AI integration
kimi*.prgKimi (Moonshot) AI integration
transformer.cPure C transformer neural network (Karpathy-style)
embed*.prgText embeddings and vector search
agent*.prgAI agents with tool use and function calling

web/ (39 samples)

WebView2 browser embedding, HTTP server creation, WebSocket connections, REST API clients, and JavaScript-to-Harbour interop.

Key FilesDescription
webview*.prgEmbedded Chromium browser (WebView2)
httpd*.prgBuilt-in HTTP server with TWebServer
websock*.prgWebSocket client/server
rest*.prgREST API client examples

DesktopWeb/ (1 sample)

One PRG for desktop and web with a single HTML/CSS/JS UI. An embedded multi-thread HTTP server (port 8080) serves login + clinic dashboard; TWebView2 navigates to the same URL as any browser.

Key FilesDescription
login.prg Shared login/dashboard; build with build.bat (hm64 -mt)

system/ (41 samples)

System-level programming: Windows registry, system services, DLL calls, process management, clipboard operations, environment variables, and more.

FiveUI/ (17 samples)

The FiveWin Visual Forms Designer. Design dialogs visually and generate .prg source code automatically. See also the visual/ directory at the project root for the full Visual IDE.

misc/ (467 samples)

The largest collection, covering virtually every FiveWin feature. When you need to see how a specific class or function works, search here first. Notable sub-topics:

test/ (317 samples)

The FiveWin test suite and additional examples. Many of these are regression tests that also serve as documentation for edge cases and specific feature behaviors.

test/fwunit/ — automated regression suite

samples/test/fwunit/ is a self-contained unit-test harness for the FWH library (142 assertions). It covers Unicode, CP1252 strings, codepage translation, formatting, system metrics, PalBmp resources, WinAPI message posting, and UI controls. Results are written to fwunit_results.log via LogFile().

Build and run:

cd samples\test\fwunit
run_all.bat

Or build only the suite: C:\fwteam\samples\build_new.bat run_fwunit hm32 then run_fwunit.exe. Run a single instance at a time.

bigexe/ (16 samples)

Complete, larger application examples that combine multiple FiveWin features into real-world programs. Study these to understand how to structure a full FWH application with menus, toolbars, multiple dialogs, database access, and reporting.

Complete Sample Directory

FolderCountLevelDescriptionStart With
start/8BeginnerStep-by-step tutorialstutor01.prg
database/19IntermediateDatabase operations, XBrowse, SQLdbfbrowse.prg
data/16IntermediateTDatabase, TDataRow, data bindingtdatabase.prg
menus/14IntermediatePull-down, popup, ribbon, context menusmenu01.prg
report/41IntermediatePrinting, reports, PDF generationreport01.prg
graphics/28IntermediateGDI+, charts, bitmaps, imagesgdiplus01.prg
mail/5IntermediateSMTP, POP3, Outlook emailsendmail.prg
ole/8IntermediateWord & Excel automationexcel01.prg
trees/5IntermediateTreeView control examplestree01.prg
comm/10IntermediateSerial communicationscomm01.prg
unicode/2IntermediateUnicode supportunicode01.prg
ai/47AdvancedOpenAI, Ollama, Gemini, Grok, DeepSeek, Agentsopenai01.prg
web/39AdvancedWebView2, HTTP server, WebSockets, RESTwebview01.prg
system/41AdvancedRegistry, services, DLL callssysinfo.prg
FiveUI/17AdvancedVisual forms designerfiveui.prg
misc/467AdvancedExtensive collection of all FWH featuresBrowse by topic
test/317AdvancedTest suite and examplestest/fwunit/run_all.bat
bigexe/16AdvancedLarge application examplesbigapp01.prg

Tips for Learning from Samples

Anatomy of a FiveWin Sample

Every sample follows the same basic structure:

#include "FiveWin.ch"     // Required: loads all FWH commands

function Main()           // Entry point

   local oWnd             // Declare local variables

   DEFINE WINDOW oWnd ... // Create UI objects using commands
   ACTIVATE WINDOW oWnd   // Start the event loop

return nil

The #include "FiveWin.ch" line is essential — it loads the preprocessor commands that translate high-level syntax like DEFINE WINDOW into class method calls.

Next Steps