Click here to Skip to main content
15,667,736 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi !...experienced...i am new with MFC and i have done normal mouse wheel in my application but now i want to mouse Click Scrolling for my application.i have two view and i want simultaniousaly scrolling in both but it not scrolling in both only in single but normal scrolling is done in both.i am using this function(see below)for it..may you help me something ?
void CsdView::OnMButtonDown(UINT nFlags, CPoint point) 
	CPoint ptScroll = GetScrollPosition();
	CsdMainFrm* pMainFrm = ( CsdMainFrm* )::AfxGetMainWnd();
    VERIFY( pMainFrm );
    CsdChildFrame* pChildFrm = ( CsdChildFrame* ) pMainFrm->MDIGetActive();
    VERIFY( pChildFrm );
	 if( c_bScrollingInitiator )
        c_bScrollingInitiator = FALSE;
        c_bScrollingInitiator = TRUE;
        pChildFrm->SetScrollView( ptScroll, c_nPane );
	  InvalidateRect( &c_rectHeadingMostRecent );
    CWindowScroller *ws = new CWindowScroller (this, point);
Updated 21-Apr-11 2:45am
Toniyo Jackson 21-Apr-11 8:45am    
Use pre tag for code

1 solution

It is very easy using nFlags variable. Here is the sample code:

BOOL CClickScrollingDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)<br />
{<br />
	if(nFlags == MK_MBUTTON)<br />
	{<br />
		if(zDelta>0)<br />
			MessageBox(L"UP!!!");<br />
		else if(zDelta<0)<br />
			MessageBox(L"DOWN!!!");<br />
	}<br />
<br />
	return CDialog::OnMouseWheel(nFlags, zDelta, pt);<br />
Share this answer
Parmod Nehra 29-Apr-11 0:13am    
thanks for your reply...but i don't want to it. because it is already becoming in my project. Actualy i want middle mouse button press(click) is also available in my application but i have two view and i want simultaneously scrolling in both view.i have been written code(above) for both view together scrolling but i didn't may you help me for both view together scrolling(middle mouse button press scrolling) ?
Viktor Signaievskyi 11-May-11 16:45pm    
Do you want to press middle button and scroll simultaneously? Am I right?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900