分页控件包装器类





5.00/5 (5投票s)
1999年12月16日

60871

1403
本文介绍了一个分页控件的包装器类
类 CCJPagerCtrl
使用起来相当简单。 它可以用于对话框或视图中。 为了演示目的,我将其在对话框中使用 CToolBar
实现,但你可以使用任何控件或视图类作为子窗口。 在资源编辑器中打开你的对话框,并添加一个自定义控件。 按照以下所示修改控件的属性
在 OnInitDialog()
部分,添加以下代码
// 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);