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

DATATypeDescription
aPromptsArrayArray of column header caption strings
aSizesArrayArray of column widths in pixels
bActionBlockCode block executed on column click. Receives nItem index and Self.

Methods

MethodDescription
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

See Also