System Controls
The System tab contains non-visual and low-level controls that provide timer functionality and custom drawing surfaces.
TTimer CT_TIMER = 38
Non-visual component that fires an event at regular intervals. Used for periodic tasks such as polling, animations, auto-save, and status updates. Does not appear on the form at runtime.
| Property | Type | Default | Description |
nInterval | Numeric | 1000 | Timer interval in milliseconds |
lEnabled | Logical | .T. | Whether the timer is active |
| Event | Category | Description |
OnTimer | Action | Fired each time the interval elapses |
| Platform | Implementation |
| Windows | SetTimer() / WM_TIMER |
| macOS | NSTimer (scheduledTimerWithTimeInterval:) |
| Linux | g_timeout_add() |
// Auto-save every 30 seconds
TIMER oTimer OF oForm INTERVAL 30000
oTimer:OnTimer := { || AutoSave() }
// Temporarily disable timer
oTimer:lEnabled := .F.
// Re-enable with faster interval
oTimer:nInterval := 5000
oTimer:lEnabled := .T.
TPaintBox CT_PAINTBOX = 39
Custom drawing surface. Provides a Canvas object for free-form painting using lines, rectangles, ellipses, text, and images. The OnPaint event is called whenever the control needs to be redrawn.
| Property | Type | Default | Description |
oCanvas | Canvas | (auto) | Drawing surface object with pen, brush, and font |
nWidth, nHeight | Numeric | 200, 200 | Size of the drawing area |
nClrPane | Color | CLR_WHITE | Background color |
| Event | Category | Description |
OnPaint | Draw | Control needs repainting (receives oCanvas) |
OnClick | Action | Surface clicked |
OnMouseDown | Mouse | Mouse button pressed (nRow, nCol, nFlags) |
OnMouseMove | Mouse | Mouse moved over surface |
OnMouseUp | Mouse | Mouse button released |
| Platform | Implementation |
| Windows | Owner-drawn STATIC (WM_PAINT + GDI/GDI+) |
| macOS | NSView (drawRect: + Core Graphics) |
| Linux | GtkDrawingArea (draw signal + Cairo) |
// Custom drawing on a PaintBox
@ 10, 10 PAINTBOX oPaint OF oForm SIZE 300, 200
oPaint:OnPaint := { |oCanvas|
oCanvas:FillRect( 0, 0, 300, 200, CLR_WHITE )
oCanvas:SetPen( CLR_BLUE, 2 )
oCanvas:DrawRect( 20, 20, 280, 180 )
oCanvas:DrawEllipse( 50, 50, 250, 150 )
oCanvas:DrawText( 110, 90, "Hello Canvas!" )
}
2 System Controls
Timer provides periodic event firing for background tasks, while PaintBox offers a free-form
drawing canvas. Both are essential for building interactive and dynamic applications.