TPanel
Source: source/classes/tpanel.prg
Inherits from: TControl
TPanel is a container control that hosts child controls with support for transparency, custom background color, and an optional border. It is commonly used to group related controls visually within a dialog or window. The panel can be designed at runtime or linked to a dialog resource.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aControls | Array | Array of child controls hosted on the panel |
nOpacity | Numeric | Opacity level from 0 (transparent) to 255 (opaque) |
nClrPane | Numeric | Background fill color (RGB value) |
Methods
| Method | Description |
|---|---|
New( nTop, nLeft, nBottom, nRight, oWnd, lDesign, cVar, lBorder ) | Create a new panel control |
Redefine( nId, oWnd ) | Redefine from a dialog resource |
Paint() | Paint the panel background and border |
GotFocus( hCtlLost ) | Handle focus arrival; forward to child controls |
Example: Panel with Child Controls
#include "FiveWin.ch"
function Main()
local oWnd, oPanel
DEFINE WINDOW oWnd TITLE "TPanel Demo" SIZE 500, 400
@ 20, 20 PANEL oPanel SIZE 460, 200 OF oWnd ;
TRANSPARENT COLOR CLR_BTNFACE
@ 30, 40 SAY "Name:" OF oPanel SIZE 40, 12
@ 30, 90 GET ... OF oPanel SIZE 120, 20
@ 60, 40 SAY "Email:" OF oPanel SIZE 40, 12
@ 60, 90 GET ... OF oPanel SIZE 180, 20
@ 100, 40 BUTTON "Save" OF oPanel SIZE 60, 25
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- Use the
TRANSPARENTclause to make the panel background see-through. When transparent, child controls draw directly on the parent window background. - The
COLORclause setsnClrPanefor the background fill when transparency is disabled. - TPanel supports design-mode editing when
lDesignis true, allowing drag-and-drop repositioning of child controls at runtime during development. - The panel handles focus management by forwarding
GotFocusevents to the first child control.