Condividi tramite


CPagerCtrl::RecalcSize

Causes the current pager control to recalculate the size of the contained window.

void RecalcSize();

Requirements

Header: afxcmn.h

Remarks

This method sends the PGM_RECALCSIZE message, which is described in the Windows SDK. Consequently, the pager control sends the PGN_CALCSIZE notification to obtain the scrollable dimensions of the contained window.

Example

The following example uses the CPagerCtrl::RecalcSize method to request the current pager control to recalculate its size.

void CCSplitButton_s2Dlg::OnXRecalcsize()
{
    // If the child control changes size, call RecalcSize() to change
    // the size of the pager control accordingly.
    m_pager.RecalcSize(); 
    MessageBox(_T("The pager control size has been recalculated."));
}

The following example uses message reflection to enable the pager control to recalculate its own size instead of requiring the control's parent dialog to perform the calculation. The example derives the MyPagerCtrl class from the CPagerCtrl class, then uses a message map to associate the PGN_CALCSIZE notification with the OnCalcsize notification handler. In this example, the notification handler sets the width and height of the pager control to fixed values.

BEGIN_MESSAGE_MAP(CMyPagerCtrl, CPagerCtrl)
        ON_NOTIFY_REFLECT(PGN_CALCSIZE, &CMyPagerCtrl::OnCalcSize)
END_MESSAGE_MAP()

// CMyPagerCtrl message handlers
void CMyPagerCtrl::OnCalcSize(NMHDR* code, LRESULT* param)
{
// If the control contained in the pager control changes size, use this
// handler to change the size of the pager control accordingly.

        LPNMPGCALCSIZE tmp = (LPNMPGCALCSIZE)code;
        *param = 0;
        tmp->iWidth = 500;
        tmp->iHeight = 50;
}

See Also

Concepts

CPagerCtrl Class

CPagerCtrl Members

Hierarchy Chart

PGM_RECALCSIZE

PGN_CALCSIZE