TStatusBar
Fonte: source/classes/statusba.prg
Inherits from: TControl
TStatusBar wraps the Windows status bar common control to display a multi-pane status bar at the bottom of a window. It supports an arbitrary number of panes with individual widths and text, an integrated clock, and automatic message display with a configurable timeout.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cMsgDef | Character | Default status bar message text |
oTimer | Object | Internal timer for message timeout and clock updates |
nPartTime | Numeric | Pane index reserved for the clock display |
Methods
| Method | Description |
|---|---|
New( oWnd, cText, aWidths, aPrompts, lClock ) | Create a new TStatusBar control |
SetMsg( cText ) | Set the status bar text (typically from oWnd:SetMsg()) |
SetParts( aWidths ) | Define pane widths as an array of numeric values |
SetPartText( nPart, cText ) | Set the text of a specific pane by index |
GetParts() | Return the current pane width definitions |
ClockOn() | Enable the clock display in the last pane |
Example: 3-Pane Status Bar with Clock
#include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "StatusBar Demo" SIZE 600, 400
DEFINE STATUSBAR oWnd PROMPT "Ready" ;
CLOCK ;
PARTS 150, 300
// Set text in individual panes
oWnd:oStatusBar:SetPartText( 2, "User: Admin" )
oWnd:oStatusBar:SetPartText( 3, "Records: 42" )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The status bar is automatically created at the bottom of the window. The
DEFINE STATUSBARcommand provides the most convenient syntax;TStatusBar():New()can be used for programmatic creation. - Pane widths in
SetParts()are specified as pixel values. The last pane always stretches to fill the remaining space regardless of its specified width. - The
CLOCKclause (orClockOn()) enables a real-time clock in the rightmost pane, updated every second via an internal timer. - Messages set via
SetMsg()are displayed in the first (leftmost) pane. The message automatically reverts tocMsgDefafter the timeout period defined bynPartTime. - TStatusBar uses the Windows status bar common control (msctls_statusbar32), which provides automatic sizing and positioning at the bottom of the parent window.