Pager ControlsPager Controls*
*Contents  *Index  *Topic Contents
*Previous Topic: MONTHDAYSTATE
*Next Topic: Pager Control Reference

Pager Controls


A pager control is a window container that is used with a window that does not have enough display area to show all of its content. The pager control allows the user to scroll to the area of the window that is not currently in view.

arrowy.gifAbout Pager Controls

arrowy.gifUsing Pager Controls

arrowy.gifPager Control Reference

About Pager Controls

Microsoft® Internet Explorer Version 4.0 introduces the pager control. This control is useful in situations where a window does not have enough area to display a child window. For example, if your application has a toolbar that is not wide enough to show all of its items, you can assign the toolbar to a pager control and users will be able to scroll to the left or right to access all of the items. You can also create pager controls that scroll vertically.

A window assigned to the pager control is referred to as the contained window.

The following illustration shows a toolbar contained inside of a pager control. The pager control is displayed in red to show what areas of the control are visible.

Note The pager control is implemented in version 4.71 and later of Comctl32.dll.

Using Pager Controls

This section describes how to implement the pager control in your application.

Initializing the Pager Control

To use the pager control, you must call InitCommonControlsEx with the ICC_PAGESCROLLER_CLASS flag set in the dwICC member of the INITCOMMONCONTROLSEX structure.

Creating the Pager Control

Use the CreateWindow or the CreateWindowEx API to create a pager control. The class name for the control is WC_PAGESCROLLER, which is defined in Commctrl.h. The PGS_HORZ style is used to create a horizontal pager, and the PGS_VERT style is used to create a vertical pager. Because this is a child control, the WS_CHILD style should also be used.

Once the pager control is created, you will most likely want to assign a contained window to it. If the contained window is a child window, you should make the child window a child of the pager control so that the size and position will be calculated correctly. You then assign the window to the pager control with the PGM_SETCHILD message. Be aware that this message does not actually change the parent window of the contained window; it simply assigns the contained window. If the contained window is one of the common controls, it must have the CCS_NORESIZE style to prevent the control from attempting to resize itself to the pager control's size.

Processing Pager Control Notifications

At a minimum, it is necessary to process the PGN_CALCSIZE notification. If you don't process this notification and enter a value for the width or height, the scroll arrows in the pager control will not be displayed. This is because the pager control uses the width or height supplied in the PGN_CALCSIZE notification to determine the "ideal" size of the contained window.

The following example demonstrates how to process the PGN_CALCSIZE notification case. In this example, the contained window is a toolbar control that contains an unknown number of buttons at an unknown size. The example shows how to use the TB_GETMAXSIZE message to determine the size of all of the items in the toolbar. The example then places the width of all of the items into the iWidth member of the NMPGCALCSIZE structure passed to the notification.

case PGN_CALCSIZE:
  {
  LPNMPGCALCSIZE   pCalcSize = (LPNMPGCALCSIZE)lParam;

  switch(pCalcSize->dwFlag)
     {
     case PGF_CALCWIDTH:
        {
        SIZE  size;

        //Get the optimum width of the toolbar.
        SendMessage(hwndToolbar, TB_GETMAXSIZE, 0, (LPARAM)&size);
        pCalcSize->iWidth = size.cx;
        }
        break;

     }

  }
  return 0;

Processing the PGN_SCROLL notification is optional. Process this notification if you need to know when a scroll action occurs, need to track the scroll position, or wish to change the scroll delta. To cancel the scroll, simply place zero in the iScroll member of the NMPGSCROLL structure passed to the notification.

The following example shows how to modify the scroll delta.

case PGN_SCROLL:
  {
  LPNMPGSCROLL   pScroll = (LPNMPGSCROLL)lParam;

  switch(pScroll->iDir)
     {
     case PGF_SCROLLLEFT:
     case PGF_SCROLLRIGHT:
     case PGF_SCROLLUP:
     case PGF_SCROLLDOWN:
        pScroll->iScroll = 20;
        break;
     }
  }
  return 0;

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.