There are two approaches to panning - TrackPan and the PanStart, PanMoveTo, and PanStop group. TrackPan is the easiest to use as it takes care of all the mouse events, performs the pan, and refreshes the display when the pan is complete.
See the How to create an advanced pan tool tip for another pan sample that uses the PanStart approach. This sample also shows how to make a pan tool that works in all views and magnifier windows and works almost identically to ArcMap's pan tool.
How to use
- Add a UIToolControl to any toolbar.
- Right-click on the tool and select view source.
- Paste the code below into VBA. Make sure the names of the UIControls matches.
- Close VBA to enable mouse events.
- Use the command to pan the focus map.
Option Explicit
Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
Dim pScreenDisplay As IScreenDisplay
Dim pActiveView As IActiveView
Dim pMxDoc As IMxDocument
Set pMxDoc = Application.Document
Set pActiveView = pMxDoc.FocusMap
Set pScreenDisplay = pActiveView.ScreenDisplay
pScreenDisplay.TrackPan
End Sub