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

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds