A pager control wrapper class





5.00/5 (5 votes)
Dec 16, 1999

60341

1403
This article presents a wrapper class for the pager control
The class CCJPagerCtrl
is fairly simple to use. It can be used in either a dialog or view.
For demo purposes, I implemented it in a dialog using a CToolBar
, but you can use any control
or view class as the child window. Open your dialog in your resource editor and add a custom control.
Modify the properties of the control as shown below:
In the OnInitDialog()
section, add the following code:
// TODO: Add extra initialization here if( !m_wndToolBar.Create(&m_Pager) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } // Make the toolbar flat. m_wndToolBar.ModifyStyle(0, 0x0800); // Set the child HWND. m_Pager.SetChild(m_wndToolBar.m_hWnd); // Set the pager style to PGS_HORZ. m_Pager.ModifyStyle(0,PGS_HORZ); // Set the button size to 15. m_Pager.SetButtonSize(15); // Determine size of child SIZE Size; m_wndToolBar.SendMessage(TB_GETMAXSIZE,0,(LPARAM)&Size); // Set the scroll area for pager. m_Pager.SetScrollArea(Size.cx+15, Size.cy+15);