Auto-Panning Windows

It implements an MFC extension class that adds IntelliMouse panning to CScrollView or any window with scroll bars. There is already one example of this in circulation (George Shepherd and Scot Wingo at MSJ Dec97) but the implementation is quite weak. Their version caused lots of flickering, incorrect paintings etc. So I wrote my own auto-panning windows extention.

As part of the IntelliMouse specification, a variety of cursors defined to be used in IntelliMouse panning. When a user clicks the mouse wheel / middle mouse button to initiate scrolling or moves the cursor back to the neutral zone (the area around the panning origin), one of three standard cursors appears, telling the user what level of panning support is provided.

Auto-Panning Windows Example imageIndicates when two-dimensional panning is supported.
Auto-Panning Windows Example imageIndicates that vertical-only, one-dimensional panning is available.
Auto-Panning Windows Example imageIndicates that horizontal-only, one-dimensional panning is available.

This is achieved through creating only one addition control named CWheelWnd. The control is very simple. It creates a floating popup window over the scrolling window, and controls the movements of the scrolling window until presses mouse wheel button. To add this functionality to your CScrollView based window or any other scrolling window add the following code to your OnMButtonDown function.
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);
    }
}

Also, given resources must be included to the project with given IDs.

 
Resource	ID
--------------  -------------
autopan.bmp	IDC_AUTOPAN
pan_up.cur	IDC_PAN_UP
pan_down.cur	IDC_PAN_DOWN
pan_left.cur	IDC_PAN_LEFT
pan_right.cur	IDC_PAN_RIGHT
Happy Scrolling :)

Download demo project - 38KB

Download source - 4.9KB

Date Posted: 5/6/98
Posted by: Pat Laplante.



Comments

  • There are no comments yet. Be the first to comment!

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

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds