CPropertySheet上面添加CPropertyPage,当CPropertySheet的尺寸小于CPropertyPage时,如何自动添加滚动条?

解决方案 »

  1.   

    不要想错了,其实就是给propertypage添加滚动条,我当前的项目刚好有这样的.
    CScrollBar * m_vbar; //For vertical Scroll Bar
    CScrollBar * m_hbar; //For Horizontal Scroll Bar.
    CBatteryViewPage::OnInitDialog()
    m_hbar = new CScrollBar;
    m_vbar = new CScrollBar;
    m_hbar->Create(SBS_HORZ /*| SBS_TOPALIGN */| WS_CHILD|WS_VISIBLE,
    CRect(0,0,0,0),//CRect(ClientRect.left,ClientRect.bottom/*-16*/,ClientRect.right/*-15*/,ClientRect.bottom), 
    this, IDC_HSCROLLBARCTRL);
    m_hbar->ShowScrollBar(); m_vbar->Create(SBS_VERT /*| SBS_LEFTALIGN */| WS_CHILD | WS_VISIBLE, 
    CRect(0,0,0,0),//CRect(ClientRect.right/*-16*/, ClientRect.top, ClientRect.right, ClientRect.bottom/*-15*/), 
    this, IDC_VSCROLLBARCTRL);
    m_vbar->ShowScrollBar();//这些确定滚动条矩形的数据都无效,为什么? 因为在onsize里面.....void CBatteryViewPage::OnSize(UINT nType, int cx, int cy)
    {
    CPropertyPage::OnSize(nType, cx, cy); CRect rcClient(0,0,0,0);
    GetClientRect(rcClient);
    rcClient.DeflateRect( 20,20,20,20); m_pBatteryControl->SetWndArea(rcClient);
    //当窗口改变时,滚动条随之移动,滚动条的信息也及时更新
    //Horizontal Scroll Info Structure
    if ( &horz && m_hbar)
    {
    horz.cbSize = sizeof(SCROLLINFO);
    horz.fMask = SIF_ALL;
    horz.nMin = 0;
    horz.nMax = m_pBatteryControl->GetHScrollRange();
    horz.nPage = rcClient.Width();
    horz.nPos = 0;
    horz.nTrackPos = 16;
    m_hbar->SetScrollInfo(&horz);
    }
    if (&vert && m_vbar)
    {
    //Vertical Scroll Info Structure
    vert.cbSize = sizeof(SCROLLINFO);
    vert.fMask = SIF_ALL;
    vert.nMin = 0;
    vert.nMax = m_pBatteryControl->GetVScrollRange();
    vert.nPage = rcClient.Height();
    vert.nPos = 0;
    vert.nTrackPos = 8;
    m_vbar->SetScrollInfo(&vert);
    }
    CRect hrect;
    hrect.left = 0;
    hrect.top = cy - 17;
    hrect.right = cx /*- 15*/;
    hrect.bottom = cy; CRect vrect;
    vrect.left = cx - 17;
    vrect.top = 0;
    vrect.right = cx;
    vrect.bottom = cy /*- 15*/; if(m_hbar != NULL)
    {
    m_hbar->MoveWindow(&hrect);//s水平滚动条适应窗口
    }
    if(m_vbar != NULL)
    {
    m_vbar->MoveWindow(&vrect);
    }
    CPaintDC dc(this);
    // m_pBatteryControl->UpdateAllBatteryRect();}
      

  2.   

    然后就添加OnHScroll和OnVScroll,处理你想滚动条的效果.