CScrollBar::Create
Creates the Windows scroll bar and attaches it to the CScrollBar object.
virtual BOOL Create(
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
UINT nID
);
Parameters
dwStyle
Specifies the scroll bar's style. Apply any combination of scroll-bar styles to the scroll bar.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 object. It must not be NULL.nID
The scroll bar's control ID.
Return Value
Nonzero if successful; otherwise 0.
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:
WS_CHILD Always
WS_VISIBLE Usually
WS_DISABLED Rarely
WS_GROUP To group controls
Example
// Example 1:
// Create a horizontal CScrollBar control as a child window of CMyDialog
// class (a CDialog-derived class). The scroll bar is NOT visible until the
// call ShowScrollBar() is made. m_ScrollBarHorz is of type CScrollBar class,
// and it is a member variable in CMyDialog class.
VERIFY(m_ScrollBarHorz.Create(SBS_HORZ | SBS_TOPALIGN | WS_CHILD,
CRect(5, 5, 100, 30), this, IDC_SCROLLBARCTRL));
m_ScrollBarHorz.ShowScrollBar();
// Example 2:
// Create a vertical CScrollBar control as a child window of CMyDialog
// class (a CDialog-derived class). m_ScrollBarVert is of type CScrollBar
// class, and it is a member variable in CMyDialog class.
VERIFY(m_ScrollBarVert.Create(SBS_VERT | SBS_LEFTALIGN | WS_CHILD |
WS_VISIBLE, CRect(5, 30, 30, 130), this, IDC_SCROLLBARCTRL));
Requirements
Header: afxwin.h