CScrollBar::Create

Syntax

BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );

Parameters

dwStyle

Specifies the scroll bar's style.

rect

Specifies the scroll bar's size and position. Can be either a RECT structure or a CRect object.

pParentWnd

Specifies the scroll bar's parent window, usually a CDialog or CModalDialog object. It must not be NULL.

nID

The scroll bar's resource ID.

Remarks

You construct a CScrollBar object in two steps. First call the constructor, which constructs the CScrollBar object, then call Create, which creates and initializes the associated Windows scroll bar and attaches it to the CScrollBar object.

Apply the following window styles to a scroll bar:

Style Application

WS_CHILD Always.
WS_VISIBLE Usually.
WS_DIABLED Rarely.
WS_GROUP To group controls.
WS_TABSTOP To allow tabbing to reach this scroll bar control.

See CreateEx in the CWnd base class for a full description of these window styles.

Use any combination of the following scroll bar styles for dwStyle:

SBS_BOTTOMALIGN

Used with the SBS_HORZ style. The bottom edge of the scroll bar is aligned with the bottom edge of the rectangle specified in Create. The scroll bar has the default height for system scroll bars.

SBS_HORZ

Designates a horizontal scroll bar. If neither the SBS_BOTTOMALIGN nor SBS_TOPALIGN style is specified, the scroll bar has the height, width, and position given in the Create member function.

SBS_LEFTALIGN

Used with the SBS_VERT style. The left edge of the scroll bar is aligned with the left edge of the rectangle specified in the Create member function. The scroll bar has the default width for system scroll bars.

SBS_RIGHTALIGN

Used with the SBS_VERT style. The right edge of the scroll bar is aligned with the right edge of the rectangle specified in the Create member function. The scroll bar has the default width for system scroll bars.

SBS_SIZEBOX

Designates a size box. If neither the SBS_SIZEBOXBOTTOMRIGHTALIGN nor SBS_SIZEBOXTOPLEFTALIGN style is specified, the size box has the height, width, and position given in the Create member function.

SBS_SIZEBOXBOTTOMRIGHTALIGN

Used with the SBS_SIZEBOX style. The lower-right corner of the size box is aligned with the lower-right corner of the rectangle specified in the Create member function. The size box has the default size for system size boxes.

SBS_SIZEBOXTOPLEFTALIGN

Used with the SBS_SIZEBOX style. The upper-left corner of the size box is aligned with the upper-left corner of the rectangle specified in the Create member function. The size box has the default size for system size boxes.

SBS_TOPALIGN

Used with the SBS_HORZ style. The top edge of the scroll bar is aligned with the top edge of the rectangle specified in the Create member function. The scroll bar has the default height for system scroll bars.

SBS_VERT

Designates a vertical scroll bar. If neither the SBS_RIGHTALIGN nor SBS_LEFTALIGN style is specified, the scroll bar has the height, width, and position given in the Create member function.

Return Value

TRUE if successful; otherwise FALSE.

See Also

CScrollBar::CScrollBar