Creates a control in the current active form, window, or dialog.
HeaderCtrl text$, id%, x, y, width, height[, style%]
text$:control text
id%:control identifier
x,y,b,h:iexp
style%:the control styles
A header control is a window that is usually positioned above columns of text or numbers. It contains a title for each column, and it can be divided into parts. The user can drag the dividers that separate the parts to set the width of each column.
Creates a control without an OCX wrapper; so it and cannot be handled using properties, methods, and event subs. When used in a form the WM_COMMAND and WM_NOTIFY messages should be handled in the form's _Message sub.
Note the requirement for the commctrl.inc.lg32 library to run the following example.
'
' HeaderCtrl Example
'
$Library "..\..\Include\commctrl.inc.lg32"
Dlg 3D On
Global style%, style2%, file$
Local phdi As HD_ITEM, hdl As HDLAYOUT, rcParent As RECT
Static hdrt$() : Array hdrt$() = "Column1" #10 "Column2" #10 "Column3" #10
Dlg Base Unit
style% = WS_BORDER | HDS_BUTTONS | HDS_HORZ
style2% = BS_DEFPUSHBUTTON | WS_TABSTOP
Dialog # 1, 10, 10, 150, 100, "Test-Dialog", WS_SYSMENU | WS_THICKFRAME
Dlg Base Pixel
HeaderCtrl "", 101, 0, 0, _X, 24, style%
phdi.Mask = HDI_FORMAT | HDI_WIDTH
phdi.fmt = HDF_LEFT | HDF_STRING // Left-justify the item
phdi.Mask |= HDI_TEXT // The .pszText member is valid
phdi.pszText = V:hdrt$(0) // The text for the item
phdi.cxy = 75 // The initial width
phdi.cchTextMax = lstrlen(phdi.pszText)
SendMessage Dlg(1, 101), HDM_INSERTITEM, 0, V:phdi
phdi.pszText = V:hdrt$(1) // The text for the 1 item
phdi.cchTextMax = lstrlen(phdi.pszText)
SendMessage Dlg(1, 101), HDM_INSERTITEM, 1, V:phdi
DlgBase Unit
PushButton "OK", IDOK, 10, 60, 40, 14, style2%
PushButton "CANCEL", IDCANCEL, 80, 60, 40, 14, style2%
EndDialog
ShowDialog # 1
Me.AutoClose = 1
Trace Dlg_1.IsDialog
Do
Sleep
Until Me Is Nothing
Sub Dlg_1_Message(hWnd%, Mess%, wParam%, lParam%)
Dim nmhdr As Pointer NMHDR
Select Mess
Case WM_SIZE
If wParam != SIZE_MINIMIZED _
SizeW Dlg(1, 101), LoWord(lParam), 24
Case WM_COMMAND
Select wParam
Case IDOK
file$ = _Win$(Dlg(1, 101))
CloseDialog # 1
Case IDCANCEL
CloseDialog # 1
EndSelect
Case WM_NOTIFY
Pointer nmhdr = lParam
EndSelect
EndSub
This command is particular useful for a dialog box in a GLL, because a GLL doesn't support OCX controls.
With the general Control statement any control type can be created.
Control, AnimateCtrl, AutoCheckBox, AutoRadioButton, CheckBox, ComboBox, CText, Dialog, DefPushButton, EditText, GroupBox, HeaderCtrl, ListBox, ListViewCtrl, LText, ProgressCtrl, PushButton, RadioButton, RichEditCtrl, RText, ScrollBar, StatusCtrl, TabCtrl, ToolBarCtrl, TrackBarCtrl, TreeViewCtrl, UpDownCtrl
{Created by Sjouke Hamstra; Last updated: 09/10/2014 by James Gaite}