本文介绍了CWindowScroller类,用于鼠标中键滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CWindowScroller这个类用于在两个视图中一起滚动鼠标中键.您可以在这里查看:
http://www.codeproject.com/KB/miscctrl/windowscroller.aspx

滚动是通过将CWindowScroller类的对象放入OnMButtonDown函数来完成的,就像

I used CWindowScroller the class for middle mouse press scrolling together in two views. you can check here :
http://www.codeproject.com/KB/miscctrl/windowscroller.aspx

scrolling is done by making object of CWindowScroller class into OnMButtonDown function,like

void CsdView::OnMButtonDown(UINT nFlags, CPoint point)      
{
    CWindowScroller *ws = new CWindowScroller (this, point);
}



其实我在控件"和测试"这两个视图上都有watemark.但是这些都没有得到刷新.我已经通过使用InvalidateRect()函数进行垂直,水平和鼠标滚轮滚动来完成刷新,但是它无法用于OnMButtonDown函数.鼠标滚轮的示例,可以正常工作,但不能通过鼠标中键滚动.示例:



Actually i have watemark on both view like "Control" and "Test".but these are not getting refresh.I have done refresh by using InvalidateRect() function for vertical,horizantal and mouse wheel scrolling, but it is not working into OnMButtonDown function. The example of Mouse Wheel, that is working fine ,but not middle mouse press scrolling.Example :

BOOL CsdView::OnMouseWheel(UINT fFlags, short zDelta, CPoint point)
{
    CPoint ptScroll = GetScrollPosition();
    CsdMainFrm* pMainFrm = ( CsdMainFrm* )::AfxGetMainWnd();
    VERIFY( pMainFrm );
    CsdChildFrame* pChildFrm = ( CsdChildFrame* ) pMainFrm->MDIGetActive();
    VERIFY( pChildFrm );
	 if( c_bScrollingInitiator )
    {
        c_bScrollingInitiator = FALSE;
    }
    else
    {
        c_bScrollingInitiator = TRUE;
        pChildFrm->SetScrollView( ptScroll, c_nPane );
    }
   InvalidateRect( &c_rectHeadingMostRecent );
	  
	  // we can''t get out of it--perform the scroll ourselves	
    return DoMouseWheel(fFlags, zDelta, point);
}


有人可以帮助我吗?


any one can help me ?

推荐答案


这篇关于CWindowScroller类,用于鼠标中键滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 14:50