Rotating the MapControl display


PurposeThis sample primarily demonstrates setting the MapControl's rotation property and secondarily demonstrates setting the MapControl MouseIcon and MousePointer properties.

The MouseIcon property is set to a custom icon stored in a resource file using the IPictureDisp LoadResFile method in the FormLoad event. This MouseIcon will be used whenever the MousePointer property is set to esriPointerCustom. The Browse dialog box allows users to search and select map documents, which are validated and loaded into the MapControl using the CheckMxFile and LoadMxFile methods. The OnBeforeScreenDraw and OnAfterScreenDraw events are used to set the MousePointer while the display is refreshing due to Extent changes.

The OnMouseDown event uses either the TrackRectangle method to zoom in or the IScreenDisplay RotateStart method to start rotating around the center of the display based on the current mouse location. The OnMouseMove event uses the IScreenDisplay RotateMoveTo and RotateTimer methods to move and redraw the display to the screen. The OnMouseUp event uses the IScreenDisplay RotateStop method to determine the angle of rotation. The MapControl's rotation property is set to this angle, and the display is refreshed to reflect the change.

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. Load a map document into the MapControl.
  2. Click to zoom in and right-click to rotate the display.

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

Download the files for all languages

See Also:

MapControl class
IMapControl2 interface