TMyBox
Source: source/classes/tmybox.prg
Inherits from: TControl
TMyBox is a colored group box control with a customizable title. Unlike the standard group box, TMyBox supports custom colors for the title text, title background, and border, along with optional centered title alignment and half-width rendering.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cTitle | Character | Title text displayed in the box header |
nClrTitleText | Numeric | Title text color (RGB value) |
nClrTitleBack | Numeric | Title background fill color (RGB value) |
nClrBorder | Numeric | Border line color (RGB value) |
lTitleCenter | Logical | Center the title text horizontally on the box |
lHalfWidth | Logical | Render the box at half the specified width |
Methods
| Method | Description |
|---|---|
New( oWnd, nT, nL, nH, nW, cTitle, nClrTT, nClrTB, nClrB ) | Create a new colored group box with optional color values |
ReDefine( nId, oWnd, cTitle ) | Redefine from a dialog resource by control ID |
SetTitle( c ) | Change the title text at runtime |
Paint() | Draw the box border, title background, and title text |
Commands
@ nRow, nCol MYBOX oBox TITLE cText SIZE nW, nH OF oDlg
Example: Blue-Titled Box
#include "FiveWin.ch"
function Main()
local oWnd, oBox
DEFINE WINDOW oWnd TITLE "TMyBox Demo" SIZE 400, 300
@ 20, 20 MYBOX oBox TITLE "Customer Info" ;
SIZE 360, 150 OF oWnd
oBox:nClrTitleText := CLR_WHITE
oBox:nClrTitleBack := CLR_BLUE
oBox:nClrBorder := CLR_BLUE
oBox:lTitleCenter := .T.
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- TMyBox is purely visual and does not clip child controls; it draws a decorative frame and title only.
- Set color values to
nilin the constructor to use system default colors for each element. - The
lHalfWidthflag is useful when the box is placed in a resizable dialog and should adapt to the available space. - Use
SetTitle()to update the title dynamically, for example when the language or context changes.