TGroup
Source: source/classes/group.prg
Inherits from: TControl
TGroup provides a group box control that visually groups related controls inside a rectangular frame with an optional label in the upper-left corner. It supports 3D etched or raised borders, transparent backgrounds, custom text and pane colors, and can host child controls. Group boxes are commonly used in dialogs to organize input fields into logical sections.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cCaption | Character | Label text displayed in the upper-left corner of the group box frame. |
aControls | Array | Array of child controls hosted inside the group box area. |
lTransparent | Logical | If .T., the group box background is transparent, allowing the parent background to show through. |
nClrText | Numeric | Text color for the caption label (RGB value). |
nClrPane | Numeric | Background fill color for the group box area (RGB value). |
l3D | Logical | If .T., the border is drawn with a 3D etched or raised effect. Default is .T.. |
cMsg | Character | Message bar text displayed when the group box receives focus. |
lDesign | Logical | If .T., the control operates in design mode, allowing child repositioning. |
Methods
| Method | Description |
|---|---|
New( nTop, nLeft, nBottom, nRight, cLabel, oWnd, lPixel, lDesign, nClrT, nClrP, cMsg, lTransparent, oFont, l3D ) | Create a new group box. Coordinates define the frame rectangle. cLabel is the caption text. The frame is drawn with a 3D etched border by default. |
ReDefine( nId, cLabel, oWnd ) | Redefine a group box from a dialog resource. The control is linked to an existing Win32 group box by its control ID. |
Paint() | Draw the group box frame, caption, and background. Handles 3D border rendering and transparent fill. |
SetCaption( cCaption ) | Change the group box caption text dynamically. |
End() | Destroy the control and remove it from the parent window. |
Commands: @ ... GROUP
@ nRow, nCol GROUP oGrp ;
PROMPT cText ;
SIZE nW, nH ;
[ OF oDlg ] ;
[ COLOR nClrText, nClrPane ] ;
[ TRANSPARENT ] ;
[ NO3D ]
Example: Group with Label
#include "FiveWin.ch"
function Main()
local oWnd, oGroup, cName := Space( 30 ), cEmail := Space( 50 )
DEFINE WINDOW oWnd TITLE "TGroup Demo" SIZE 500, 300
@ 10, 10 GROUP oGroup PROMPT "Personal Information" ;
SIZE 460, 200 OF oWnd
@ 30, 30 SAY "Name:" OF oWnd SIZE 50, 12
@ 30, 90 GET cName OF oWnd SIZE 200, 20
@ 60, 30 SAY "Email:" OF oWnd SIZE 50, 12
@ 60, 90 GET cEmail OF oWnd SIZE 300, 20
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- TGroup inherits from TControl. All standard methods (
Move(),Refresh(),SetFocus(), etc.) are available. - Use
TRANSPARENTwhen the group box is placed over a gradient or bitmap background. The interior will be see-through, and the caption will draw directly on the parent background. - The
NO3Dclause (or settingl3D := .F.) draws a simple flat border instead of the default etched 3D look. - Controls placed inside the group box are children of the group box only if the
@ ... OF oGroupsyntax is used. Otherwise, they are children of the parent dialog. - Use
COLOR nClrText, nClrPaneto customize the caption text color and the background fill.