Adding an Item to a Header Control

The following example demonstrates how to use the HDM_INSERTITEM message and the HD_ITEM structure to add an item to a header control. The new item consists of a string that is left-justified within the item rectangle.

// DoInsertItem - inserts items into a header control.

// Returns the index of the newly added item.

// hwndHeader - handle of the header control

// iInsertAfter - index of the previous item

// nWidth - width of the new item

// lpsz - address of the item string

int DoInsertItem(HWND hwndHeader, int iInsertAfter,

int nWidth, LPSTR lpsz)

{

HD_ITEM hdi;

int index;

hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_WIDTH;

hdi.pszText = lpsz;

hdi.cxy = nWidth;

hdi.cchTextMax = lstrlen(hdi.pszText);

hdi.fmt = HDF_LEFT | HDF_STRING;

index = SendMessage(hwndHeader, HDM_INSERTITEM,

(WPARAM) iInsertAfter, (LPARAM) &hdi);

return index;

}

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples