Share via


CHeaderCtrl::Create

BOOLCreate(DWORDdwStyle**,constRECT&rect,CWnd*pParentWnd,UINTnID);**

Return Value

Nonzero if initialization was successful; otherwise zero.

Parameters

dwStyle

Specifies the header control’s style. Apply any combination of header control styles needed to the control.

rect

Specifies the header control’s size and position. It can be either a CRect object or a structure.

pParentWnd

Specifies the header control’s parent window, usually a CDialog. It must not be NULL.

nID

Specifies the header control’s ID.

Remarks

You construct a CHeaderCtrl object in two steps. First call the constructor, then call Create, which creates the header control and attaches it to the CHeaderCtrl object.

The following styles can be applied to a header control (see for more information):

  • HDS_HOTTRACK   A header item is highlighted when the pointer pauses over it.

  • HDS_DRAGDROP   Header items can be reordered by dragging and dropping them.

  • HDS_FULLDRAG   The header control to displays column contents while the user resizes a column.

  • HDS_BUTTONS   Header items behave like buttons.

  • HDS_HORZ   The header control is horizontal.

  • HDS_VERT   The header control is vertical (this style is not currently implemented).

  • HDS_HIDDEN   The header control is not visible in details mode.

In addition, you can use the following common control styles to determine how the header control positions and resizes itself (see for more information):

  • CCS_BOTTOM   Causes the control to position itself at the bottom of the parent window’s client area and sets the width to be the same as the parent window’s width.

  • CCS_NODIVIDER   Prevents a two-pixel highlight from being drawn at the top of the control.

  • CCS_NOHILITE   Prevents a one-pixel highlight from being drawn at the top of the control.

  • CCS_NOMOVEY   Causes the control to resize and move itself horizontally, but not vertically, in response to a WM_SIZE message. If the CCS_NORESIZE style is used, this style does not apply. Header controls have this style by default.

  • CCS_NOPARENTALIGN   Prevents the control from automatically moving to the top or bottom of the parent window. Instead, the control keeps its position within the parent window despite changes to the size of the parent window. If the CCS_TOP or CCS_BOTTOM style is also used, the height is adjusted to the default, but the position and width remain unchanged.

  • CCS_NORESIZE   Prevents the control from using the default width and height when setting its initial size or a new size. Instead, the control uses the width and height specified in the request for creation or sizing.

  • CCS_TOP   Causes the control to position itself at the top of the parent window’s client area and sets the width to be the same as the parent window’s width.

You can also apply the following window styles to a header control (see Window Styles for more information):

  • WS_CHILD   Creates a child window. Cannot be used with the WS_POPUP style.

  • WS_VISIBLE   Creates a window that is initially visible.

  • WS_DISABLED   Creates a window that is initially disabled.

  • WS_GROUP   Specifies the first control of a group of controls in which the user can move from one control to the next with the arrow keys. All controls defined with the WS_GROUP style after the first control belong to the same group. The next control with the WS_GROUP style ends the style group and starts the next group (that is, one group ends where the next begins).

  • WS_TABSTOP   Specifies one of any number of controls through which the user can move by using the TAB key. The TAB key moves the user to the next control specified by the WS_TABSTOP style.

Example

// pParentWnd is a pointer to the parent window.
extern CWnd* pParentWnd;
// The pointer to my header control.
extern CHeaderCtrl* pmyHeaderCtrl;

pmyHeaderCtrl->Create(WS_CHILD|WS_VISIBLE|HDS_HORZ,
   CRect(10, 10, 600, 50), pParentWnd, 1);

CHeaderCtrl OverviewClass MembersHierarchy Chart

See Also   CHeaderCtrl::CHeaderCtrl