Add Move Element

Created:9/4/2001
Description:

The Microsoft Common Dialog Control (Comdlg32.ocx) allows users to search and select map documents, which are validated and loaded into the PageLayoutControl using the CheckMxFile and LoadMxFile methods.

NorthArrows, ScaleBars and ScaleText MapSurroundFrames are added to the GraphicsContainer of the PageLayoutControl using the AddElement method which is passed a default geometry. Each MapSurroundFrame contains a MapSurround selected by the user from the StyleSelector. A legend MapSurroundFrame element is created in a similar way, but uses a default legend style. A title is added to the GraphicsContainer as a TextElement, once the user has formatted the default text with the TextSymbolEditor. The esriViewGraphics phase is refreshed to view these changes. The Background, Border, and Shadow StyleSelectors allow users to change the properties of the MapFrame, whilst the MapGrid StyleSelector allows users to add a MapGrid to the MapFrame. The esriViewBackground phase is refreshed to view these changes.

The OnMouseDown event of the PageLayoutControl uses the TrackRectangle method to zoom in if the middle or right hand mouse button has been used. The ZoomToWholePage method is used to zoom to the extent of the page. The left hand button determines whether a SelectionTracker exists. If a SelectionTracker does not exist or the current mouse location does not intersect the SelectionTracker the TrackRectangle method is used return an envelope. If any elements are located within the envelope, a new SelectionTracker is created and drawn on the display. If a SelectionTracker does exist and it intersects the mouse location, a MoveImageFeedback is created and the element is drawn into the feedacks display. The OnMouseMove event of the PageLayoutControl displays an image of the element at the mouse location. The OnMouseUp event of the PageLayoutControl ends the feedback and moves the element by an offest, calculated from the start and end mouse locations. The esriViewGraphics phase is refreshed to reflect the elements new location.

The PageLayoutControls OnKeyDown event determines whether the delete key has been pressed. If it has, and there is an element with a SelectionTracker, the element is deleted from the GraphicsContainer of the PageLayoutControl, and the esriViewGraphics phase is refreshed to reflect the change.



How to use:
  1. Either run the AddMoveElement.exe or open the AddMoveElement.vbp and run from within the project.
  2. Add a title, north arrow, scale bar and legend element to the map and change the map frames background, border and shadow properties.
  3. Use the left hand mouse button to select and move an element and the right hand mouse button to zoom in. Delete selected elements with the delete key.

Application:
Page Layout Control

Minimum ArcGIS Version Required: 8.2

Difficulty: Beginner


Visual Basic
File Description
AddMoveElement.frm VB form file for the AddMoveElement project.
AddMoveElement.frx VB Binary file.
AddMoveElement.vbp VB Project file.


Key CoClasses: PageLayoutControl
Key Interfaces: IDisplayFeedback, IMapFrame, IMapSurround, IMapSurroundFrame, IMoveImageFeedback, ISelectionTracker, IStyleSelector, ITextSymbolEditor, ITransform2D
Key Members: ActiveView, AddElement, CheckMxFile, Extent, GraphicsContainer, Hwnd, LoadMxFile, MousePointer, Refresh, TrackRectnagle, ZoomToWholePage