Arrow key and mouse wheel navigation of the MapControl display


PurposeThis sample illustrates how the MapControl can be configured to pan around the display using the arrow keys on the keyboard and to zoom in and out of the display using the mouse wheel, when the MapControl has focus. A dashed outline is placed around the MapControl when it has focus.

Most container forms or dialog boxes use the arrow keys to change control focus and do not pass these key values onto the MapControl. The IMapControl3::KeyIntercept property allows these keys to be intercepted before the container form or dialog box processes them. The IMapControl4::AutoKeyboardScrolling property is used to enable automatic panning of the display when the arrow keys are intercepted and the IMapControl4::AutoMouseWheel property is used to enable automatic zooming on the display with the mouse wheel.

Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView
ArcEditor
ArcInfo

How to use

See Using the samples for help on compiling, setting up the debugger, and running the sample (either an exe or dll).

  1. Click Load to load a document; you can edit the document file name on the form.
  2. Set form focus to the map, either by clicking it or tabbing to it.
  3. Use the arrow keys to pan the map.

AssemblyInfo.cs Assembly information
ArrowKeyPan.cs Form file
Download the C# files
AssemblyInfo.vb Assembly information
ArrowKeyPan.vb Form file
Download the VB.NET files

Download the files for all languages

See Also:

MapControl class
IMapControl4 interface
IMapControl3 interface