THeader
Source: source/classes/theader.prg
Inherits from: TControl
THeader is a wrapper for the Win32 SysHeader32 common control. It provides a clickable, resizable column header bar typically used above list views or custom grid controls. Each column can display a prompt, have a specific width, support click-to-sort arrows, and fire an action when clicked. The control supports hot-track highlighting and full-drag column resizing.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aPrompts | Array | Array of column header caption strings |
aSizes | Array | Array of column widths in pixels |
bAction | Block | Code block executed on column click. Receives nItem index and Self. |
Methods
| Method | Description |
|---|---|
New( oWnd, nTop, nLeft, nW, nH, aPrompts, aSizes, oFont, nClrFore, nClrBack, bAction ) | Create a new THeader control |
ReDefine( nId, oWnd, aPrompts, aSizes, oFont, nClrFore, nClrBack, bAction ) | Redefine from dialog resource |
InsertItem( nIndex, cCaption, nWidth, nAlign ) | Insert a new column at the specified position |
SetItem( nIndex, cCaption, nWidth, nAlign, nSort ) | Modify an existing column's properties |
GetItem( nIndex ) | Retrieve column information (caption, width, alignment) |
Example: Three-Column Header with Click Action
#include "FiveWin.ch"
function Main()
local oWnd, oHeader, aPrompts, aSizes
aPrompts := { "Name", "Date", "Size" }
aSizes := { 150, 100, 80 }
DEFINE WINDOW oWnd TITLE "Header Demo" SIZE 400, 200
oHeader := THeader():New( oWnd, 10, 10, 380, 22, aPrompts, aSizes,,, ;
, { | nItem, oCtrl | MsgInfo( "Column " + Str( nItem ) ) } )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- THeader wraps the
SysHeader32common control (orSysHeaderon Clipper). It is registered with theWC_HEADERwindow class. - Columns support hot-track highlighting (
HDS_HOTTRACK) and full-drag resizing (HDS_FULLDRAG). - When the themed mode is active (
IsAppThemed()), the control applies theHDS_FLATstyle for a modern appearance. - The
bActioncode block fires onHDN_ITEMCLICKnotifications, receiving the column index (1-based) and the THeader object as parameters. - Use
SetItem()with thenSortparameter to display a sort arrow indicator (up or down) on a column. - Column alignment is controlled by the
nAlignparameter inInsertItem()/SetItem(), usingHDF_LEFT,HDF_CENTER, orHDF_RIGHTconstants.