
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. The following illustration shows a header control that has labeled columns that give detailed information about files in a directory.
Header Control Updates in Internet Explorer
You can create a header control by using the CreateWindowEx function, specifying the WC_HEADER window class and the appropriate header styles. This window class is registered when the common control dynamic-link library (DLL) is loaded. To ensure that this DLL is loaded, use the InitCommonControls function. After you create a header control, you can divide it into parts, set the text in each part, and control the appearance of the window by using header window messages.
Typically, you must set the size and position of a header control to fit within the boundaries of a particular rectangle, such as the client area of a window. By using the HDM_LAYOUT message, you can retrieve the appropriate size and position values from the header control.
When sending HDM_LAYOUT, you specify the address of an HDLAYOUT structure that contains the coordinates of the rectangle that the header control is to occupy and provides a pointer to a WINDOWPOS structure. The control fills the WINDOWPOS structure with size and position values appropriate for positioning the control along the top of the specified rectangle. The height value is the sum of the heights of the control's horizontal borders and the average height of characters in the font currently selected into the control's device context.
If you want to use HDM_LAYOUT to set the initial size and position of a header control, set the initial visibility state of the control so that it is hidden. After sending HDM_LAYOUT to retrieve the size and position values, you can use the SetWindowPos function to set the new size, position, and visibility state.
A header control typically has several header items that define the columns of the control. You add an item to a header control by sending the HDM_INSERTITEM message to the control. The message includes the address of an HDITEM structure. This structure defines the properties of the header item, which can include a string, a bitmapped image, an initial size, and an application-defined 32-bit value.
The fmt member of an item's HDITEM structure can include either the HDF_STRING or HDF_BITMAP flag to indicate whether the control displays the item's string or bitmap. If you want to display both a string and a bitmap, create an owner-drawn item by setting the fmt member to include the HDF_OWNERDRAW flag. The HDITEM structure also specifies formatting flags that tell the control whether to center, left-align, or right-align the string or bitmap in the item's rectangle.
HDM_INSERTITEM returns the index of the newly added item. You can use the index in other messages to set properties or retrieve information about the item. You can delete an item by using the HDM_DELETEITEM message, specifying the index of the item to delete.
You can use the HDM_SETITEM message to set the properties of an existing header item and the HDM_GETITEM message to retrieve the current properties of an item. To retrieve a count of the items in a header control, use the HDM_GETITEMCOUNT message.
You can define individual items of a header control to be owner-drawn items. Using this technique gives you more control than you would otherwise have over the appearance of a header item.
You can use the HDM_INSERTITEM message to insert a new owner-drawn item into a header control or the HDM_SETITEM message to change an existing item to an owner-drawn item. Both messages include the address of an HDITEM structure, which should have the fmt member set to the HDF_OWNERDRAW value.
When a header control must draw an owner-drawn item, it sends the WM_DRAWITEM message to the parent window. The wParam parameter of the message is the child window identifier of the header control, and the lParam parameter is an address of a DRAWITEMSTRUCT structure. The parent window uses the information in the structure to draw the item. For an owner-drawn item in a header control, the DRAWITEMSTRUCT structure contains the following information.
| Member | Description |
| CtlType | ODT_HEADER owner-drawn control type. |
| CtlID | Child-window identifier of the header control. |
| itemID | Index of the item to be drawn. |
| itemAction | ODA_DRAWENTIRE drawing-action flag. |
| itemState | ODS_SELECTED drawing-action flag if the cursor is on the item and the mouse button is down. Otherwise, this member is zero. |
| hwndItem | Handle to the header control. |
| hDC | Handle to the device context of the header control. |
| rcItem | Coordinates of the header item to be drawn. The coordinates are relative to the upper-left corner of the header control. |
| itemData | Application-defined 32-bit value associated with the item. |
A header control sends notification messages to its parent window when the user clicks or double-clicks an item, when the user drags an item divider, and when the attributes of an item change. The parent window receives the notifications in the form of WM_NOTIFY messages. The following notifications are used with header controls.
| Notification | Description |
| HDN_BEGINTRACK | Signals the start of divider dragging. |
| HDN_DIVIDERDBLCLICK | Indicates that the user double-clicked a divider. |
| HDN_ENDTRACK | Signals the end of divider dragging. |
| HDN_ITEMCHANGED | Indicates a change in the attributes of an item. |
| HDN_ITEMCHANGING | Indicates that the attributes of an item are about to change. |
| HDN_ITEMCLICK | Indicates that the user clicked an item. |
| HDN_ITEMDBLCLICK | Indicates that the user double-clicked an item. |
| HDN_TRACK | Indicates that the user dragged a divider. |
This section describes the window messages handled by the window procedure for the WC_HEADER window class.
| Message | Processing performed |
| WM_CREATE | Initializes the header control. |
| WM_DESTROY | Uninitializes the header control. |
| WM_ERASEBKGND | Fills the background of the header control using the control's current background color. |
| WM_GETDLGCODE | Returns a combination of the DLGC_WANTTAB and DLGC_WANTARROWS values. |
| WM_GETFONT | Returns the handle to the current font, which is used by the header control to draw its text. |
| WM_LBUTTONDBLCLK | Captures mouse input. If the mouse cursor is on a divider, the control sends the HDN_BEGINTRACK notification message and begins dragging the divider. If the cursor is on an item, the item is displayed in the pressed state. |
| WM_LBUTTONDOWN | Same as the WM_LBUTTONDBLCLK message. |
| WM_LBUTTONUP | Releases the mouse capture. If the control was tracking mouse movement, it sends the HDN_ENDTRACK notification message and redraws the header control. Otherwise, the control sends the HDN_ITEMCLICK notification message and redraws the header item that was clicked. |
| WM_MOUSEMOVE | If a divider is being dragged, the control sends the HDN_TRACK notification message and displays the item at the new position. If the left mouse button is down and the cursor is on an item, the item is displayed in the pressed state. |
| WM_NCCREATE | Allocates and initializes an internal data structure. |
| WM_NCDESTROY | Frees the resources allocated by the header control after the header control is uninitialized. |
| WM_PAINT | Paints the invalid region of the header control. If the wParam parameter is non-NULL, the control assumes that the value is an HDC and paints using that device context. |
| WM_SETCURSOR | Sets the cursor shape, depending on whether the cursor is on a divider or in a header item. |
| WM_SETFONT | Selects a new font handle into the device context for the header control. |
The following example demonstrates how to create a header control and position it along the top of the parent window's client area. The control is initially hidden. The HDM_LAYOUT message is used to calculate the size and position of the control within the parent window. The control is then repositioned and made visible.
// DoCreateHeader - creates a header control that is positioned along
// the top of the parent window's client area.
// Returns the handle to the header control.
// hwndParent - handle to the parent window.
//
// Global variable
// g_hinst - handle to the application instance
extern HINSTANCE g_hinst;
HWND DoCreateHeader(HWND hwndParent)
{
HWND hwndHeader;
RECT rcParent;
HDLAYOUT hdl;
WINDOWPOS wp;
// Ensure that the common control DLL is loaded, and then create
// the header control.
InitCommonControls();
if ((hwndHeader = CreateWindowEx(0, WC_HEADER, (LPCTSTR) NULL,
WS_CHILD | WS_BORDER | HDS_BUTTONS | HDS_HORZ,
0, 0, 0, 0, hwndParent, (HMENU) ID_HEADER, g_hinst,
(LPVOID) NULL)) == NULL)
return (HWND) NULL;
// Retrieve the bounding rectangle of the parent window's
// client area, and then request size and position values
// from the header control.
GetClientRect(hwndParent, &rcParent);
hdl.prc = &rcParent;
hdl.pwpos = ℘
if (!SendMessage(hwndHeader, HDM_LAYOUT, 0, (LPARAM) &hdl))
return (HWND) NULL;
// Set the size, position, and visibility of the header control.
SetWindowPos(hwndHeader, wp.hwndInsertAfter, wp.x, wp.y,
wp.cx, wp.cy, wp.flags | SWP_SHOWWINDOW);
return hwndHeader;
}
The following example demonstrates how to use the HDM_INSERTITEM message and the HDITEM 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 an item into a header control.
// Returns the index of the new item.
// hwndHeader - handle to 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)
{
HDITEM 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;
}
Header controls in Microsoft® Internet Explorer support the following new features.
This section contains information about the programming elements used with header controls.
| Structures |
| HD_HITTESTINFO |
| HD_ITEM |
| HD_LAYOUT |
| HD_NOTIFY |
| HDHITTESTINFO |
| HDITEM |
| HDLAYOUT |
| NMHDDISPINFO |
| NMHEADER |
Header controls have a number of styles, described below, that determine the control's appearance and behavior. You set the initial styles when you create the header control. To retrieve and change the styles after creating the control, use the GetWindowLong and SetWindowLong functions.
This section includes information about the messages for header controls.
HDM_CREATEDRAGIMAGE
wParam = (WPARAM) (int) iIndex;
lParam = 0;
Creates a semi-transparent version of an item's image for use as a dragging image. You can send this message explicitly or use the Header_CreateDragImage macro.
Version 4.70
HDM_DELETEITEM
wParam = (WPARAM) (int) index;
lParam = 0;
Deletes an item from a header control. You can send this message explicitly or use the Header_DeleteItem macro.
HDM_GETIMAGELIST
wParam = 0;
lParam = 0;
Retrieves the handle to the image list that has been set for an existing header control. You can send this message explicitly or use the Header_GetImageList macro.
Version 4.70
HDM_GETITEM
wParam = (WPARAM) (int) index;
lParam = (LPARAM) (LPHDITEM) phdi;
Retrieves information about an item in a header control. You can send this message explicitly or use the Header_GetItem macro.
HDM_GETITEMCOUNT
wParam = 0;
lParam = 0;
Retrieves a count of the items in a header control. You can send this message explicitly or use the Header_GetItemCount macro.
HDM_GETITEMRECT
wParam = (WPARAM) (int) iIndex;
lParam = (LPARAM) lpItemRect;
Retrieves the bounding rectangle for a given item in a header control. You can send this message explicitly or use the Header_GetItemRect macro.
Version 4.70
HDM_GETORDERARRAY
wParam = (WPARAM) (int) iSize;
lParam = (LPARAM) (LPINT) lpiArray;
Retrieves the current left-to-right order of items in a header control. You can send this message explicitly or use the Header_GetOrderArray macro.
int iItems,
*lpiArray;
// Get memory for buffer.
(iItems = SendMessage(hwndHD, HDM_GETITEMCOUNT, 0,0))!=-1)
if(!(lpiArray = calloc(iItems,sizeof(int))))
MessageBox(hwnd, "Out of memory.","Error", MB_OK);
Version 4.70
HDM_GETUNICODEFORMAT
wParam = 0;
lParam = 0;
Retrieves the UNICODE character format flag for the control. You can send this message explicitly or use the Header_GetUnicodeFormat macro.
See also HDM_SETUNICODEFORMAT
HDM_HITTEST
wParam = 0;
lParam = (LPARAM) (LPHDHITTESTINFO) phdhti;
Tests a point to determine which header item, if any, is at the specified point.
HDM_INSERTITEM
wParam = (WPARAM) (int) index;
lParam = (LPARAM) (const LPHDITEM) phdi;
Inserts a new item into a header control. You can send this message explicitly or use the Header_InsertItem macro.
HDM_LAYOUT
wParam = 0;
lParam = (LPARAM) (LPHDLAYOUT) playout;
Retrieves the correct size and position of a header control within the parent window. You can send this message explicitly or use the Header_Layout macro.
HDM_ORDERTOINDEX
wParam = (WPARAM) iOrder;
lParam = 0;
Retrieves an index value for an item based on its order in the header control. You can send this message explicitly or use the Header_OrderToIndex macro.
Version 4.70
HDM_SETHOTDIVIDER
wParam = (WPARAM) flag;
lParam = (LPARAM) dwInputValue;
Changes the color of a divider between header items to indicate the destination of an external drag-and-drop operation. You can send this message explicitly or use the Header_SetHotDivider macro.
| TRUE | Indicates that dwInputValue holds the client coordinates of the pointer. |
| FALSE | Indicates that dwInputValue holds a divider index value. |
If flag is TRUE, dwInputValue represents the x- and y-coordinates of the pointer. The x-coordinate is in the low word, and the y-coordinate is in the high word. When the header control receives the message, it highlights the appropriate divider based on the dwInputValue coordinates.
If flag is FALSE, dwInputValue represents the integer index of the divider to be highlighted.
This message creates an effect that a header control automatically produces when it has the HDS_DRAGDROP style. The HDM_SETHOTDIVIDER message is intended to be used when the owner of the control handles drag-and-drop operations manually.
Version 4.70
HDM_SETIMAGELIST
wParam = 0;
lParam = (LPARAM) himl;
Assigns an image list to an existing header control. You can send this message explicitly or use the Header_SetImageList macro.
Version 4.70
HDM_SETITEM
wParam = (WPARAM)(int) iIndex;
lParam = (LPARAM)(const LPHDITEM) phdItem;
Sets the attributes of the specified item in a header control. You can send this message explicitly or use the Header_SetItem macro.
The HDITEM structure that supports this message supports item order and image list information. By using these members, you can control the order in which items are displayed and specify images to appear with items.
HDM_SETORDERARRAY
wParam = (WPARAM) (int) iSize;
lParam = (LPARAM) lpiArray;
Sets the left-to-right order of header items. You can send this message explicitly or use the Header_SetOrderArray macro.
Version 4.70
HDM_SETUNICODEFORMAT
wParam = (WPARAM)(BOOL)fUnicode;
lParam = 0;
Sets the UNICODE character format flag for the control. This message allows you to change the character set used by the control at run time rather than having to re-create the control. You can send this message explicitly or use the Header_SetUnicodeFormat macro.
See also HDM_GETUNICODEFORMAT
This section contains information about header control macros.
HIMAGELIST Header_CreateDragImage(
HWND hwndHD,
int iIndex
);
Creates a transparent version of an item image within an existing header control. You can use this macro or send the HDM_CREATEDRAGIMAGE message explicitly.
Version 4.70
BOOL Header_DeleteItem(
hwndHD,
index
);
Deletes an item from a header control. You can use this macro or send the HDM_DELETEITEM message explicitly.
The Header_DeleteItem macro is defined as follows:
#define Header_DeleteItem(hwndHD, index) \
(BOOL)SendMessage((hwndHD), HDM_DELETEITEM, (WPARAM)(int)(index), 0L)
HIMAGELIST Header_GetImageList(HWND hwndHD);
Retrieves the handle to the image list that has been set for an existing header control. You can use this macro or send the HDM_GETIMAGELIST message explicitly.
Version 4.70
BOOL Header_GetItem(
hwndHD,
index,
phdi
);
Retrieves information about an item in a header control. You can use this macro or send the HDM_GETITEM message explicitly.
The Header_GetItem macro is defined as follows:
#define Header_GetItem(hwndHD, index, phdi) \
(BOOL)SendMessage((hwndHD), HDM_GETITEM, \
(WPARAM)(int)(index), (LPARAM)(LPHDITEM)(phdi))
int Header_GetItemCount(
hwndHD
);
Retrieves a count of the items in a header control. You can use this macro or send the HDM_GETITEMCOUNT message explicitly.
The Header_GetItemCount macro is defined as follows:
#define Header_GetItemCount(hwndHD) \
(int)SendMessage((hwndHD), HDM_GETITEMCOUNT, 0, 0L)
BOOL Header_GetItemRect(
HWND hwndHD,
int iIndex,
LPRECT lpItemRect
);
Retrieves the bounding rectangle for a given item in a header control. You can use this macro or send the HDM_GETITEMRECT message explicitly.
Version 4.70
BOOL Header_GetOrderArray(
HWND hwndHD,
int iSize,
int *lpiArray
);
Retrieves the current left-to-right order of items in a header control. You can use this macro or send the HDM_GETORDERARRAY message explicitly.
int iItems,
*lpiArray;
// Get memory for buffer
if((iItems = SendMessage(hwndHD, HDM_GETITEMCOUNT, 0,0))!=-1)
if(!(lpiArray = calloc(iItems,sizeof(int))))
MessageBox(hwnd, "Out of memory.","Error", MB_OK);
Version 4.70
BOOL Header_GetUnicodeFormat(
HWND hwnd
);
Retrieves the UNICODE character format flag for the control. You can use this macro or send the HDM_GETUNICODEFORMAT message explicitly.
See also Header_SetUnicodeFormat
int Header_InsertItem(
hwndHD,
index,
phdi
);
Inserts a new item into a header control. You can use this macro or send the HDM_INSERTITEM message explicitly.
The Header_InsertItem macro is defined as follows:
#define Header_InsertItem(hwndHD, index, phdi) \
(int)SendMessage((hwndHD), HDM_INSERTITEM, (WPARAM)(int)(index), \
(LPARAM)(const LPHDITEM)(phdi))
BOOL Header_Layout(
hwndHD,
playout
);
Retrieves the correct size and position of a header control within the parent window. You can use this macro or send the HDM_LAYOUT message explicitly.
The Header_Layout macro is defined as follows:
#define Header_Layout(hwndHD, playout) \
(BOOL)SendMessage((hwndHD), HDM_LAYOUT, 0, \
(LPARAM)(PLHDLAYOUT)(playout))
int Header_OrderToIndex(
HWND hwndHD,
int iOrder
);
Retrieves an index value for an item based on its order in the header control. You can use this macro or send the HDM_ORDERTOINDEX message explicitly.
Version 4.70
int Header_SetHotDivider(
HWND hwndHD,
BOOL flag,
DWORD dwInputValue
);
Changes the color of a divider between header items to indicate the destination of an external drag-and-drop operation. You can use this macro or send the HDM_SETHOTDIVIDER message explicitly.
| TRUE | Indicates that dwInputValue holds client coordinates of the pointer. |
| FALSE | Indicates that dwInputValue holds a divider index value. |
If flag is TRUE, dwInputValue represents the x- and y- client coordinates of the pointer. The x-coordinate is in the low word, and the y-coordinate is in the high word. Upon receiving the message, the header control highlights the appropriate divider based on the dwInputValue coordinates.
If flag is FALSE, dwInputValue represents the integer index of the divider that will be highlighted.
A header control set to the HDS_DRAGDROP style produces this effect automatically. This message is intended to be used when the owner of the control handles drag-and-drop operations manually.
Version 4.70
HIMAGELIST Header_SetImageList(
HWND hwndHD,
HIMAGELIST himl
);
Assigns an image list to an existing header control. You can use this macro or send the HDM_SETIMAGELIST message explicitly.
Version 4.70
BOOL Header_SetItem(
hwndHD,
iIndex;
phdItem
);
Sets the attributes of the specified item in a header control. You can use this macro or send the HDM_SETITEM message explicitly.
The HDITEM structure that supports this macro supports item order and image list information. By using these members, you can control the order in which items are displayed and specify images to appear with items.
BOOL Header_SetOrderArray(
HWND hwndHD,
int iSize,
int *lpiArray
);
Sets the left-to-right order of header items. You can use this macro or send the HDM_SETORDERARRAY message explicitly.
Version 4.70
BOOL Header_SetUnicodeFormat(
HWND hwnd,
BOOL fUnicode
);
Sets the UNICODE character format flag for the control. This message allows you to change the character set used by the control at run time rather than having to re-create the control. You can use this macro or send the HDM_SETUNICODEFORMAT message explicitly.
See also Header_GetUnicodeFormat
This section contains information about the notification messages sent by header controls.
HDN_BEGINDRAG pNMHeader = (LPNMHEADER) lParam;
Sent by a header control when a drag operation has begun on one of its items. This notification message is sent only by header controls that are set to the HDS_DRAGDROP style. This notification is sent in the form of a WM_NOTIFY message.
A header control defaults to automatically managing drag-and-drop reordering. Returning TRUE to indicate external (manual) drag-and-drop management allows the owner of the control to provide custom services as part of the drag-and-drop process.
Version 4.70
HDN_BEGINTRACK
phdn = (LPNMHEADER) lParam;
Notifies a header control's parent window that the user has begun dragging a divider in the control (that is, the user has pressed the left mouse button while the mouse cursor is on a divider in the header control). This notification message is sent in the form of a WM_NOTIFY message.
HDN_DIVIDERDBLCLICK
phdn = (LPNMHEADER) lParam;
Notifies a header control's parent window that the user double-clicked the divider area of the control. This notification message is sent in the form of a WM_NOTIFY message.
HDN_ENDDRAG pNMHeader = (LPNMHEADER) lParam;
Sent by a header control when a drag operation has ended on one of its items. This notification is sent as a WM_NOTIFY message. Only header controls that are set to the HDS_DRAGDROP style send this notification.
If the owner is performing external (manual) drag-and-drop management, it must return FALSE. The owner then must reorder header items manually by sending HDM_SETITEM or HDM_SETORDERARRAY.
Version 4.70
HDN_ENDTRACK
phdn = (LPNMHEADER) lParam;
Notifies a header control's parent window that the user has finished dragging a divider. This notification message sent in the form of a WM_NOTIFY message.
HDN_GETDISPINFO pDispInfo = (LPNMHDDISPINFO) lParam;
Sent to the owner of a header control when the control needs information about a callback header item. This notification is sent as a WM_NOTIFY message.
Fill the appropriate members of the structure to return the requested information to the header control. If your message handler sets the mask member of the NMHDDISPINFO structure to HDI_DI_SETITEM, the header control stores the information and will not request it again.
Version 4.70
HDN_ITEMCHANGED
phdr = (LPNMHEADER) lParam;
Notifies a header control's parent window that the attributes of a header item have changed. This notification message is sent in the form of a WM_NOTIFY message.
HDN_ITEMCHANGING
phdr = (LPNMHEADER) lParam;
Notifies a header control's parent window that the attributes of a header item are about to change. This notification message is sent in the form of a WM_NOTIFY message.
HDN_ITEMCLICK
phdr = (LPNMHEADER) lParam;
Notifies a header control's parent window that the user clicked the control. This notification message is sent in the form of a WM_NOTIFY message.
A header control sends this notification message after the user releases the left mouse button.
HDN_ITEMDBLCLICK
pnmhdr = (LPNMHEADER) lParam;
Notifies a header control's parent window that the user double-clicked the control. This notification message is sent in the form of a WM_NOTIFY message. Only header controls that are set to the HDS_BUTTONS style send this notification.
HDN_TRACK
phdr = (LPNMHEADER) lParam;
Notifies a header control's parent window that the user is dragging a divider in the header control. This notification message is sent in the form of a WM_NOTIFY message.
NM_CUSTOMDRAW
lpNMCustomDraw = (LPNMCUSTOMDRAW) lParam;
Sent by a header control to notify its parent window about drawing operations. This notification is sent in the form of a WM_NOTIFY message.
When dwDrawStage equals CDDS_PREPAINT:
|
When dwDrawStage equals CDDS_ITEMPREPAINT:
|
Version 4.70
See also Using Custom Draw
NM_RCLICK
lpnmh = (LPNMHDR) lParam;
Notifies a tree view control's parent window that the user has clicked the right mouse button within the control. This notification is sent in the form of a WM_NOTIFY message.
NM_RELEASEDCAPTURE
lpnmh = (LPNMHDR) lParam;
Notifies a header control's parent window that the control is releasing mouse capture. This notification is sent in the form of a WM_NOTIFY message.
Version 4.71
This section contains information on the structures used to support header controls.
typedef struct _HD_HITTESTINFO {
POINT pt;
UINT flags;
int iItem;
} HDHITTESTINFO, FAR *LPHDHITTESTINFO;
Contains information about a hit test. This structure is used with the HDM_HITTEST message. This structure supersedes the HD_HITTESTINFO structure.
| HHT_NOWHERE | The point is inside the header control's bounding rectangle but is not over a header item. |
| HHT_ONDIVIDER | The point is on the divider between two header items. |
| HHT_ONDIVOPEN | The point is on the divider of an item that has a width of zero. Dragging the divider reveals the item instead of resizing the item to the left of the divider. |
| HHT_ONHEADER | The point is inside the header control's bounding rectangle. |
| HHT_TOLEFT | The point is to the left of the header control's bounding rectangle. |
| HHT_TORIGHT | The point is to the right of the header control's bounding rectangle. |
Two of these values can be combined, such as when the position is above and to the left of the client area.
typedef struct _HDITEM {
UINT mask;
int cxy;
LPTSTR pszText;
HBITMAP hbm;
int cchTextMax;
int fmt;
LPARAM lParam;
#if (_WIN32_IE >= 0x0300)
int iImage;
int iOrder;
#endif
} HDITEM, FAR * LPHDITEM;
Contains information about an item in a header control. This structure supersedes the HD_ITEM structure.
| HDI_BITMAP | The hbm member is valid. |
| HDI_FORMAT | The fmt member is valid. |
| HDI_HEIGHT | The cxy member is valid and specifies the item's height. |
| HDI_IMAGE | Version 4.70. The iImage member is valid and specifies the image to be displayed with the item. |
| HDI_LPARAM | The lParam member is valid. |
| HDI_ORDER | Version 4.70. The iOrder member is valid and specifies the item's order value. |
| HDI_TEXT | The pszText and cchTextMax members are valid. |
| HDI_WIDTH | The cxy member is valid and specifies the item's width. |
This member can include one of the following text justification or right-to-left reading order bit flags:
| HDF_CENTER | The item's contents are centered. |
| HDF_LEFT | The item's contents are left-aligned. |
| HDF_RIGHT | The item's contents are right-aligned. |
| HDF_RTLREADING | Text is displayed using right-to-left reading order for Hebrew or Arabic systems. |
The flag from the preceding list is combined with one of the following values:
| HDF_BITMAP | The item displays a bitmap. |
| HDF_BITMAP_ON_RIGHT | Version 4.70. The bitmap appears to the right of text. This does not affect an image from an image list assigned to the header item. |
| HDF_IMAGE | Version 4.70. The item displays an image from the image list. |
| HDF_OWNERDRAW | The header control's owner draws the item. |
| HDF_STRING | The item displays a string. |
Additionally, the following flag can be combined with any of the preceding flags:
| HDF_IMAGE | The item displays an image from an image list. |
You can use the HDF_JUSTIFYMASK mask to isolate the text justification portion of the fmt member.
The header control can display text, an image, and a bitmap for an item all at the same time. The alignment flags determine the order in which they appear. With HDF_LEFT or HDF_CENTER, the order is image, text, and then bitmap. With HDF_RIGHT the order is bitmap, image, and then text.
typedef struct _HD_LAYOUT {
RECT FAR* prc;
WINDOWPOS FAR* pwpos;
} HDLAYOUT, FAR *LPHDLAYOUT;
Contains information used to set the size and position of a header control. This structure is used with the HDM_LAYOUT message. This structure supersedes the HD_LAYOUT structure.
typedef struct tagNMHDDISPINFO {
NMHDR hdr;
int iItem;
UINT mask;
LPTSTR pszText;
int cchTextMax;
int iImage;
LPARAM lParam;
} NMHDDISPINFO, FAR* LPNMHDDISPINFO;
Contains information used in handling HDN_GETDISPINFO notification messages.
| HDI_TEXT | The pszText field must be filled in. |
| HDI_IMAGE | The iImage field must be filled in. |
| HDI_LPARAM | The lParam field must be filled in. |
| HDI_DI_SETITEM | A return value. Indicates that the header control should store the item information and not ask for it again. |
Version 4.70
typedef struct tagNMHEADER{
NMHDR hdr;
int iItem;
int iButton;
HDITEM FAR* pItem;
} NMHEADER, FAR* LPNMHEADER;
Contains information about header control notification messages. This structure supersedes the HD_NOTIFY structure.
| 0 | Left button |
| 1 | Right button |
| 2 | Middle button |
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.