gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
阅读:1180回复:2

如何实现在ArcMap上画Polygon

楼主#
更多 发布于:2005-08-30 15:04
用户点击按钮后,在地图上任意点击生成Polygon,双击Polygon生成完成
<P>l 要点</P>
<P>IRubberBand.TrackNew方法,</P>
<P>IActiveview.ScreenDisplay.StartDrawing,DrawPolygon和EndDrawing方法</P>
<P>l 程序说明</P>
<P>通过IRubberBand.TrackNew方法实现Polygon的作成,</P>
<P>通过IActiveview.ScreenDisplay.StartDrawing,DrawPolygon和EndDrawing方法来绘制Polygon</P>
<P>通过Map事件的重载,使绘制的Polygon不会因为Map的刷新而消失</P>
<P>l 代码</P>
<P>Private m_pPolygon                  As IPolygon<BR>Private m_pFillSymbol               As IFillSymbol<BR>Private m_pScreenDisplay            As IscreenDisplay<BR>'事件重载<BR>Private WithEvents ActiveViewEvents As Map<BR>'重新绘制Polygon<BR>Private Sub ActiveViewEvents_AfterDraw(ByVal Display As IDisplay, ByVal phase AsesriViewDrawPhase)<BR>    If Not phase = esriDPGeography Then Exit Sub<BR>    If m_pPolygon Is Nothing Then Exit Sub<BR>    With m_pScreenDisplay<BR>        .SetSymbol m_pFillSymbol<BR>        .DrawPolygon m_pPolygon<BR>    End With<BR>End Sub </P>
<P>'事件初始化<BR>Private Sub UIToolControl1_Select()<BR>    Dim pMxDoc          As IMxDocument<BR>    Set pMxDoc = ThisDocument<BR>    Set ActiveViewEvents = pMxDoc.FocusMap<BR>End Sub </P>
<P>Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, _ByVal x As Long, ByVal y As Long)<BR>    Dim pMxDoc            As IMxDocument<BR>    Dim pActiveView       As IActiveView<BR>    Dim pRubberPolygon    As IRubberBand<BR>    Dim pFillSymbol       As ISimpleFillSymbol<BR>    Dim pRgbColor         As IRgbColor<BR>    Dim pPolygon          As IPolygon<BR>    Set pMxDoc = Application.Document<BR>    Set pActiveView = pMxDoc.FocusMap<BR>    Set m_pScreenDisplay = pActiveView.ScreenDisplay<BR>    Set pRubberPolygon = New RubberPolygon<BR>    Set m_pFillSymbol = New SimpleFillSymbol<BR>    Set pRgbColor = New RgbColor<BR>    pRgbColor.Red = 255<BR>    m_pFillSymbol.Color = pRgbColor<BR>    '获得Polygon<BR>    Set m_pPolygon = pRubberPolygon.TrackNew(m_pScreenDisplay, pFillSymbol)<BR>    '绘制Polygon<BR>    With m_pScreenDisplay<BR>        .StartDrawing m_pScreenDisplay.hDC, esriNoScreenCache<BR>        .SetSymbol m_pFillSymbol<BR>        .DrawPolygon m_pPolygon<BR>        .FinishDrawing<BR>    End With<BR>End Sub</P>
喜欢0 评分0
GIS麦田守望者,期待与您交流。
cftao2008
路人甲
路人甲
  • 注册日期2005-03-09
  • 发帖数141
  • QQ
  • 铜币568枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2005-08-31 13:13
俺用了!多谢!
举报 回复(0) 喜欢(0)     评分
ahshegis
路人甲
路人甲
  • 注册日期2004-10-22
  • 发帖数181
  • QQ
  • 铜币847枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2005-09-01 14:42
如果把这段代码改到VB中第一个点就不对,第一个点总是按Button的那个点
举报 回复(0) 喜欢(0)     评分
游客

返回顶部