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.
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:
| # | File | What You Learn |
|---|---|---|
| 1 | start/tutor01.prg |
Hello World — MsgInfo(), the simplest FWH program |
| 2 | start/tutor02.prg |
Windows — DEFINE WINDOW, ACTIVATE WINDOW |
| 3 | start/tutor03.prg |
Dialogs — DEFINE DIALOG, SAY/GET controls |
| 4 | start/tutor04.prg |
Buttons & Actions — button creation, ACTION clauses, event handling |
| 5 | start/tutor05.prg |
Menus — DEFINE 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.
| File | Topic | Key Concepts |
|---|---|---|
tutor01.prg | Hello World | MsgInfo(), #include "FiveWin.ch" |
tutor02.prg | Windows | DEFINE WINDOW, ACTIVATE WINDOW, SIZE, TITLE |
tutor03.prg | Dialogs | DEFINE DIALOG, SAY, GET, ACTIVATE DIALOG |
tutor04.prg | Buttons | @ ... BUTTON, ACTION clause, CANCEL |
tutor05.prg | Menus | DEFINE MENU, MENUITEM, SEPARATOR, SET MENU |
tutor06.prg | Databases | USE, BROWSE, DBF access from FWH |
tutor07.prg | Advanced Dialogs | Multiple controls, bValid, bWhen |
tutor08.prg | Complete App | Window + 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 Files | Description |
|---|---|
dbfbrowse.prg | Basic DBF browsing with TXBrowse |
sql*.prg | SQL database connections and queries |
xbrowse*.prg | Advanced XBrowse with database sources |
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 Files | Description |
|---|---|
openai*.prg | OpenAI GPT integration via TOpenAI class |
ollama*.prg | Local LLM via Ollama REST API |
gemini*.prg | Google Gemini AI integration |
grok*.prg | xAI Grok integration |
deepseek*.prg | DeepSeek AI integration |
kimi*.prg | Kimi (Moonshot) AI integration |
transformer.c | Pure C transformer neural network (Karpathy-style) |
embed*.prg | Text embeddings and vector search |
agent*.prg | AI 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 Files | Description |
|---|---|
webview*.prg | Embedded Chromium browser (WebView2) |
httpd*.prg | Built-in HTTP server with TWebServer |
websock*.prg | WebSocket client/server |
rest*.prg | REST API client examples |
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:
- calexmaria.prg — TCalex appointment calendar with MySQL/MariaDB CRUD, drag-and-drop move between days, RC dialog editing (new in 26.05)
- Drag and drop, clipboard, system tray
- Splitter bars, docking panels
- Image viewers, video playback
- Cryptography, hashing, encoding
- File operations, ZIP/GZIP compression
- Custom control painting, owner-draw
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.
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
| Folder | Count | Level | Description | Start With |
|---|---|---|---|---|
start/ | 8 | Beginner | Step-by-step tutorials | tutor01.prg |
database/ | 19 | Intermediate | Database operations, XBrowse, SQL | dbfbrowse.prg |
data/ | 16 | Intermediate | TDatabase, TDataRow, data binding | tdatabase.prg |
menus/ | 14 | Intermediate | Pull-down, popup, ribbon, context menus | menu01.prg |
report/ | 41 | Intermediate | Printing, reports, PDF generation | report01.prg |
graphics/ | 28 | Intermediate | GDI+, charts, bitmaps, images | gdiplus01.prg |
mail/ | 5 | Intermediate | SMTP, POP3, Outlook email | sendmail.prg |
ole/ | 8 | Intermediate | Word & Excel automation | excel01.prg |
trees/ | 5 | Intermediate | TreeView control examples | tree01.prg |
comm/ | 10 | Intermediate | Serial communications | comm01.prg |
unicode/ | 2 | Intermediate | Unicode support | unicode01.prg |
ai/ | 47 | Advanced | OpenAI, Ollama, Gemini, Grok, DeepSeek, Agents | openai01.prg |
web/ | 39 | Advanced | WebView2, HTTP server, WebSockets, REST | webview01.prg |
system/ | 41 | Advanced | Registry, services, DLL calls | sysinfo.prg |
FiveUI/ | 17 | Advanced | Visual forms designer | fiveui.prg |
misc/ | 467 | Advanced | Extensive collection of all FWH features | Browse by topic |
test/ | 317 | Advanced | Test suite and examples | Browse by topic |
bigexe/ | 16 | Advanced | Large application examples | bigapp01.prg |
Tips for Learning from Samples
-
Read the source code. Every
.prgfile is plain text. Open it in any editor. The code is the documentation. - Modify and experiment. Change a color, add a button, swap a database. Rebuild and see what happens. FiveWin compiles fast.
-
Use MsgInfo() for debugging. Insert
MsgInfo( cVariable )anywhere to inspect values at runtime. It is the FiveWin developer's best friend. - Search misc/ when stuck. With 467 samples, there is almost certainly an example of whatever you need. Use your editor's "search in files" feature.
-
Look at the .ch include files. Commands like
DEFINE WINDOWare translated by the preprocessor. CheckFiveWin.chto see what they expand to. - Cross-reference with docs. When a sample uses a class like TXBrowse, open the TXBrowse documentation alongside the code.
- Join the community. The FiveTech forums are active and welcoming. Post questions with your sample code.
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
- Build System — Set up your compiler and build your first sample
- TDialog — Master dialog-based interfaces (used in most samples)
- TXBrowse — The most powerful grid control (used in database samples)
- More Classes — Additional classes with examples