TMyTitle
Source: source/classes/tmytitle.prg
Inherits from: TControl
TMyTitle is a custom gradient title bar control that can be placed at the top of a window or dialog. It renders a gradient-filled background (horizontal or vertical) with title text, an optional header bitmap, and a glass-like effect. It supports custom fonts, border colors, and runtime updates to the title text and bitmap.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cTitle | Character | Title text displayed on the gradient bar |
cBitmap | Character | Optional bitmap file path or resource name |
nClrFore | Numeric | Title text foreground color |
nClrBegin | Numeric | Gradient start color (default light blue) |
nClrEnd | Numeric | Gradient end color (default dark blue) |
lVertical | Logical | Vertical gradient orientation (default horizontal) |
lGlass | Logical | Enable glass-style gradient effect |
lBorder | Logical | Draw a border around the title bar (default .T.) |
nClrBorder | Numeric | Border color (default CLR_BLACK) |
oBitmap | Object | Loaded bitmap object (from file or resource) |
oFontTitle | Object | Font used for the title text |
nOffSetX | Numeric | Horizontal bitmap offset (default 0) |
nOffSetY | Numeric | Vertical bitmap offset (default 0) |
Methods
| Method | Description |
|---|---|
New( oWnd, nTop, nLeft, nH, nW, cTitle, nClrFore, nClrBegin, nClrEnd, nStyle, oFontTitle, lVertical, lBorder, nClrBorder, lGlass, cBitmap ) | Create a new TMyTitle control |
ReDefine( nId, oWnd, cTitle, nClrFore, nClrBegin, nClrEnd, lVertical, lBorder, nClrBorder, lGlass, cBitmap, oFontTitle ) | Redefine from dialog resource |
SetBitmap( cBmp ) | Change the header bitmap at runtime (file or resource) |
SetTitle( cTitle ) | Change the title text and refresh |
SetFont( oFont ) | Change the title font |
Example: Gradient Title Bar
#include "FiveWin.ch"
function Main()
local oWnd, oTitle
DEFINE WINDOW oWnd TITLE "Demo" SIZE 500, 300
oTitle := TMyTitle():New( oWnd, 0, 0, 50, 500,;
"My Custom Dialog", CLR_WHITE,;
nRGB( 89, 135, 214 ), nRGB( 3, 56, 147 ),,,;
.F., .T., CLR_BLACK, .F. )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The default font is Tahoma, size -18, bold. A custom font can be supplied via the
oFontTitleparameter. - When
lGlassis.T., the bar uses a two-pass horizontal gradient that creates a glass-like reflection effect. - Bitmaps can be loaded from file (path with extension) or from resource (name without extension). The bitmap is drawn at offset
nOffSetX,nOffSetYfrom the top-left corner. - High-DPI scaling is supported via
nScale, which is automatically computed from the active window's logical DPI.