Course title 1-8Lesson title
3-8Developing Applications with ArcGIS EngineCopyright © 2004 ESRI. All rights reserved.
Mapping controls: 事件
事件事件
事件
IMapControlEvents/IPageLayoutControlEvents
OnAfterDraw, OnBeforeScreenDraw, OnAfterScreenDraw,
OnExtentUpdated, OnMouseDown/Up/Move, OnKeyDown/Up,
OnOleDrop, OnViewRefreshed, OnMap/PageReplaced
Private Sub AxMapControl1_OnMouseDown(…) Handles AxMapControl1.OnMouseDown
… ‘
当点击右健按纽时
当点击右健按纽时当点击右健按纽时
当点击右健按纽时,
,,
,其就会旋转
其就会旋转其就会旋转
其就会旋转
pPoint = New Point
pPoint.PutCoords(e.mapX, e.mapY)
m_pPoint.X = m_pMapControl.Extent.XMin + (m_pMapControl.Extent.Width / 2)
m_pPoint.Y = m_pMapControl.Extent.YMin + (m_pMapControl.Extent.Height / 2)
m_pMapControl.ActiveView.ScreenDisplay.RotateStart(pPoint, m_pPoint)
End Sub
Private Sub AxMapControl1_OnMouseMove(…) Handles AxMapControl1.OnMouseMove
pPoint = New Point
pPoint.PutCoords(e.mapX, e.mapY) ‘
设置当前鼠标位置坐标
设置当前鼠标位置坐标设置当前鼠标位置坐标
设置当前鼠标位置坐标
m_pMapControl.ActiveView.ScreenDisplay.RotateMoveTo(pPoint)
m_pMapControl.ActiveView.ScreenDisplay.RotateTimer() ‘
绘制旋转显示
绘制旋转显示绘制旋转显示
绘制旋转显示
End Sub
Private Sub AxMapControl1_OnMouseUp(…) Handles AxMapControl1.OnMouseUp
Dim dRotationAngle As Double ‘
获取旋转角
获取旋转角获取旋转角
获取旋转角
dRotationAngle = m_pMapControl.ActiveView.ScreenDisplay.RotateStop
m_pMapControl.Rotation = dRotationAngle ‘
旋转
旋转旋转
旋转
MapControl
的显示
的显示的显示
的显示
m_pMapControl.Refresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography)
End Sub
Private Sub AxMapControl1_OnMouseDown(…) Handles AxMapControl1.OnMouseDown
… ‘
当点击右健按纽时
当点击右健按纽时当点击右健按纽时
当点击右健按纽时,
,,
,其就会旋转
其就会旋转其就会旋转
其就会旋转
pPoint = New Point
pPoint.PutCoords(e.mapX, e.mapY)
m_pPoint.X = m_pMapControl.Extent.XMin + (m_pMapControl.Extent.Width / 2)
m_pPoint.Y = m_pMapControl.Extent.YMin + (m_pMapControl.Extent.Height / 2)
m_pMapControl.ActiveView.ScreenDisplay.RotateStart(pPoint, m_pPoint)
End Sub
Private Sub AxMapControl1_OnMouseMove(…) Handles AxMapControl1.OnMouseMove
pPoint = New Point
pPoint.PutCoords(e.mapX, e.mapY) ‘
设置当前鼠标位置坐标
设置当前鼠标位置坐标设置当前鼠标位置坐标
设置当前鼠标位置坐标
m_pMapControl.ActiveView.ScreenDisplay.RotateMoveTo(pPoint)
m_pMapControl.ActiveView.ScreenDisplay.RotateTimer() ‘
绘制旋转显示
绘制旋转显示绘制旋转显示
绘制旋转显示
End Sub
Private Sub AxMapControl1_OnMouseUp(…) Handles AxMapControl1.OnMouseUp
Dim dRotationAngle As Double ‘
获取旋转角
获取旋转角获取旋转角
获取旋转角
dRotationAngle = m_pMapControl.ActiveView.ScreenDisplay.RotateStop
m_pMapControl.Rotation = dRotationAngle ‘
旋转
旋转旋转
旋转
MapControl
的显示
的显示的显示
的显示
m_pMapControl.Refresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography)
End Sub
The MapControl Events
Each ArcGIS Control fires events in response to keyboard and mouse interactions by the end
user. Some of the events are listed here. Other events fire in response to actions occurring
within the controls. For example, when a map document is loaded into the MapControl the
OnMapReplaced event is fired, or when an object is dragged over the MapControl via drag and
drop, the OnOleDrop event is fired.
The listed code shows some code segments on how to rotate the map display based on mouse
movements by the user.
OnAfterDraw: The OnAfterDraw event is fired after a specified phase has been drawn on the
Map's screen display and is based upon the IActiveViewEvents::AfterDraw event. You must
query for the IDisplay interface and base the viewDrawPhase on the esriViewDrawPhase
constants. You can enable or disable this event being fired by setting the
IViewManager::VerboseEvents property to true or false.
OnBeforeScreenDraw: OnBeforeScreenDraw is triggered before the
IDisplayEvents::DisplayStarted event is called on the map’s screen display. The hDC for the
display in question is passed as an argument into this event.
OnAfterScreenDraw: OnAfterScreenDraw is triggered after
the IDisplayEvents::DisplayFinished event is called on the map’s screen display, which means
after the drawing of the screen is complete.
OnExtentUpdated: OnExtentUpdated is triggered whenever the IMapControl2::Extent
property is changed. Setting the extent explicitly, zooming, panning, or using the
IMapControl2::CenterAt method will fire this method.