Intellimouse panning 2 (A universal Auto-Panning solution)

This article improves on the code submitted by Umut Alev, Auto-Panning Windows.
This article also uses some code submitted by Lutz Kretzschmar, Intellimouse panning.
This article integrates some code submitted by Russel Freeman, Auto-Panning Windows 2.

How it looks like

Improvements made to original version

  • Modified behavior and look to match IE4.
  • Added continous subpixel scrolling adapted from Lutz.
  • Modified the speed calculation to use a faster acceleration when more than 42 pixel away from start region.
  • Added support for lots of Controls and Views
  • Added style flags to customize behavior
    • MFX_WHEELWNDSTYLE_ONEDIRECTION
      No diagonal panning.
    • MFX_WHEELWNDSTYLE_UPDOWNONLY/MFX_WHEELWNDSTYLE_LEFTRIGHTONLY
      Limit panning to either UP/DOWN or LEFT/RIGHT.
    • MFX_WHEELWNDSTYLE_NOSUBPIXELSCROLLING
      No continous subpixel scrolling.
  • Moved the Resources to a RecourceTemplate for a better handling.
  • Nearly every parameter is customizable through "CAutoPanParameters"-classes.
    • Provide a own Origin-Bitmap
    • Use your own Cursors
    • Directly scroll the window with your own functions
    • Or just replace the width of one scrolling-step...
  • Of course the code does compile without any Level 4 warning.

Currently supportet Views and Controls

  • CEditView
  • CFormView
  • CListView (all modes)
  • CRichEditView
  • CScrollView
  • CTreeView
  • ComboBox (different look&feel)
  • Edit
  • ListBox
  • ListCtrl (all modes)
  • SpinButton (different look&feel)
  • TreeCtrl

Using in a View - with macros


	void CAutoPanView::OnMButtonDown(UINT nFlags, CPoint point) 
	{
		CWheelWnd_OnMButtonDown(CScrollView);
	}
 

Using in a View - without macros


	void CAutoPanView::OnMButtonDown(UINT nFlags, CPoint point) 
	{
		BOOL bCtl = GetKeyState(VK_CONTROL) & 0x8000;
		if(!bCtl && nFlags == MK_MBUTTON)
		{
			MfxTrackAutoPan(this);
		}
		else
		{
			CScrollView::OnMButtonDown(nFlags, point);
		}
	}
 

Using in a CDialog - with macros


	void CAutopanDialog::OnMButtonDown(UINT nFlags, CPoint point) 
	{
		CWheelWnd_OnMButtonDown(CDialog);
	}

	BOOL CAutopanDialog::PreTranslateMessage(MSG* pMsg) 
	{
		CWheelWnd_PreTranslateMessage(CDialog);
	}
 

Using in a CDialog - without macros


	void CAutopanDialog::OnMButtonDown(UINT nFlags, CPoint point) 
	{
		BOOL bCtl = GetKeyState(VK_CONTROL) & 0x8000;
		if(!bCtl && nFlags == MK_MBUTTON)
		{
			CWnd* pWnd = WindowFromPoint(point);
			if (pWnd) MfxTrackAutoPan(pWnd);
			else CDialog::OnMButtonDown(nFlags, point);
		}
		else
		{
			CDialog::OnMButtonDown(nFlags, point);
		}
	}

	BOOL CAutopanDialog::PreTranslateMessage(MSG* pMsg) 
	{
		if (pMsg && pMsg->message==WM_MBUTTONDOWN)
		{
			OnMButtonDown(pMsg->wParam, CPoint(pMsg->pt));
			return TRUE;
		}
		else
		{
	 		return CDialog::PreTranslateMessage(pMsg);
		}
	}
 

Download source - 12KB

Download the three source files mfxWhlPan.h, mfxWhlPan.c and mfxWhlPan.inl and the new cursors in this ZIP file. You must download either Umats demo project - 38KB and replace the two files and the cursors - or use my extended demo project - 84KB. To have a quick look the executable - 63KB is also availible.

Last updated: 6 July 1998



Comments

  • Intellimouse panning 2 (A universal Auto-Panning solution)

    Posted by Legacy on 07/03/1999 12:00am

    Originally posted by: Michael Herstine

    Great code - just one small problem. If you use CAutoPanParametersMessage, it uses the SB_THUMBPOSITION parameter with the WM_HSCROLL/WM_VSCROLL messages. Unfortunately, CScrollView doesn't check for this; it checks for SB_THUMBTRACK (which causes a fall-through in their case statement, and no scrolling). I don't know if this is an oversight or intentional on the part of MFC, but changing lines 21 & 22 of mfxWhlPan.inl from:

    pParentWnd->SendMessage(WM_HSCROLL, MAKELONG(SB_THUMBPOSITION, nScrollToX), NULL);
    pParentWnd->SendMessage(WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, nScrollToY), NULL);

    to

    pParentWnd->SendMessage(WM_HSCROLL, MAKELONG(SB_THUMBTRACK, nScrollToX), NULL);
    pParentWnd->SendMessage(WM_VSCROLL, MAKELONG(SB_THUMBTRACK, nScrollToY), NULL);

    will get things to work. Again, a really nice solution.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds