Share via


CPagerCtrl::Create

Creates a pager control with specified styles and attaches it to the current CPagerCtrl object.

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

Parameters

Parameter

Description

[in] dwStyle

A bitwise combination (OR) of window styles and pager control styles to be applied to the control.

[in] rect

A reference to a RECT structure that contains the position and size of the control in client coordinates.

[in] pParentWnd

A pointer to a CWnd object that is the parent window of the control. This parameter cannot be NULL.

[in] nID

The ID of the control.

Return Value

true if this method is successful; otherwise, false.

Requirements

Header: afxcmn.h

Remarks

To create a pager control, declare a CPagerCtrl variable, then call the CPagerCtrl::Create or CPagerCtrl::CreateEx method on that variable.

Example

The following example creates a pager control, then uses the CPagerCtrl::SetChild method to associate a very long button control with the pager control. The example then uses the CPagerCtrl::SetButtonSize method to set the height of the pager control to 20 pixels, and the CPagerCtrl::SetBorder method to set the border thickness to 1 pixel.

// Initialize the dropdown menu of the splitbutton control.
    m_splitButton.SetDropDownMenu(IDR_MENU1, 0);

    // Create the pager control.
    BOOL nRet;
    CRect rect;
    GetClientRect(&rect);
    nRet = m_pager.Create(
        (WS_VISIBLE | WS_CHILD | PGS_HORZ),
        CRect(rect.Width()/4, 5, (rect.Width() * 3)/4, 55),
        this,
        IDC_PAGER1); 

    m_pager.GetClientRect( &rect );
    nRet = m_button.Create(
        _T("This is a very, very long button. 012345678901234567890"), 
        (WS_VISIBLE | WS_CHILD), // Do not use CCS_NORESIZE.
        CRect(0,0,rect.Width(),30), 
        &m_pager, IDC_BUTTON1);

    m_pager.SetChild(m_button.m_hWnd);
    m_pager.SetButtonSize( 20 );
    m_pager.SetBorder( 1 );

See Also

Reference

CPagerCtrl Class

Hierarchy Chart

Pager Control Styles

Window Styles