共用方式為


Creating the Header Control

The header control is not directly available in the dialog editor (although you can add a list control, which includes a header control).

To put a header control in a dialog box

  1. Manually embed a member variable of type CHeaderCtrl in your dialog class.

  2. In OnInitDialog, create and set the styles for the CHeaderCtrl, position it, and display it.

  3. Add items to the header control.

  4. Use the Properties window to map handler functions in the dialog class for any header-control notification messages you need to handle (see Mapping Messages to Functions).

To put a header control in a view (not a CListView)

  1. Embed a CHeaderCtrl object in your view class.

  2. Style, position, and display the header control window in the view's OnInitialUpdate member function.

  3. Add items to the header control.

  4. Use the Properties window to map handler functions in the view class for any header-control notification messages you need to handle (see Mapping Messages to Functions).

In either case, the embedded control object is created when the view or dialog object is created. Then you must call CHeaderCtrl::Create to create the control window. To position the control, call CHeaderCtrl::Layout to determine the control's initial size and position and SetWindowPos to set the position you want. Then add items as described in Adding Items to the Header Control.

For more information, see Creating a Header Control in the Windows SDK.

See Also

Reference

Using CHeaderCtrl

Concepts

Controls (MFC)