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

  • Savvy enterprises are discovering that the cloud holds the power to transform IT processes and support business objectives. IT departments can use the cloud to redefine the continuum of development and operations—a process that is becoming known as DevOps. Download the Executive Brief DevOps: Why IT Operations Managers Should Care About the Cloud—prepared by Frost & Sullivan and sponsored by IBM—to learn how IBM SmartCloud Application services provide a robust platform that streamlines …

  • "Security" is the number one issue holding business leaders back from the cloud. But does the reality match the perception? Keeping data close to home, on premises, makes business and IT leaders feel inherently more secure. But the truth is, cloud solutions can offer companies real, tangible security advantages. Before you assume that on-site is the only way to keep data safe, it's worth taking a comprehensive approach to evaluating risks. Doing so can lead to big benefits.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds