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

  • Download the Information Governance Survey Benchmark Report to gain insights that can help you further establish business value in your Records and Information Management (RIM) program and across your entire organization. Discover how your peers in the industry are dealing with this evolving information lifecycle management environment and uncover key insights such as: 87% of organizations surveyed have a RIM program in place 8% measure compliance 64% cannot get employees to "let go" of information for …

  • When it comes to desktops – physical or virtual – it's all about the applications. Cloud-hosted virtual desktops are growing fast because you get local data center-class security and 24x7 access with the complete personalization and flexibility of your own desktop. Organizations make five common mistakes when it comes to planning and implementing their application management strategy. This eBook tells you what they are and how to avoid them, and offers real-life case studies on customers who didn't …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds