Scrollbar in CFormView does not work,why?
-
just crreating a new SDI project with VC++ wizard, choose CFormView as the base view class, then switch to the resource editor, place a CListBox control on the formview, and make sure to enlarge the formview design size so that a scrollbar can appear later, then ,build it and run, though the scrollbar is visible, but i just can't let it scroll with my middle mouse wheel, can anybody tell me what's the reason?? thanks a lot. lostangels@163.com
-
just crreating a new SDI project with VC++ wizard, choose CFormView as the base view class, then switch to the resource editor, place a CListBox control on the formview, and make sure to enlarge the formview design size so that a scrollbar can appear later, then ,build it and run, though the scrollbar is visible, but i just can't let it scroll with my middle mouse wheel, can anybody tell me what's the reason?? thanks a lot. lostangels@163.com
To perform mousewhel scrolling in a CFormView you have to enter the logic yourself. You have to respond to WM_MOUSEWHELL. Here's a snippet that worked for me: BOOL CSomeFormView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { // test if it is visible first if ( GetStyle() & WS_VSCROLL ) { CPoint ptScroll = GetScrollPosition(); // determine the amount of scrolling int nLines = -zDelta / WHEEL_DELTA; // Scroll to new position ScrollToPosition ( ptScroll + CPoint ( 0, nLines * 15 ) ); } return CFormView::OnMouseWheel(nFlags, zDelta, pt); }