pagelayoutControl中添加图元(VB)

添加文本,图例,图形比例尺,文字比例尺

Private Sub insertText_Click()

  Dim pActiveView As IActiveView

  Dim pGraphicsContainer As IGraphicsContainer

  Dim pTextElement As ITextElement, pTextSymbol As ITextSymbol, pColor As IColor

  Dim pElement As IElement, pEnvelope As IEnvelope

  Set pActiveView = pPageLayoutControl.ActiveView

  Set pGraphicsContainer = pPageLayoutControl.PageLayout

  Set pEnvelope = New Envelope

  pEnvelope.PutCoords 0, 0, 20.4, 50.4

  Set pTextElement = New TextElement

  Set pElement = pTextElement

  pElement.Geometry = pEnvelope

  pTextElement.Text = "My Map"

  Set pTextSymbol = New TextSymbol

  Set pColor = New RgbColor

  pColor.RGB = &H8000&

  pTextSymbol.Color = pColor

  pTextSymbol.size = 40

  pTextElement.Symbol = pTextSymbol

  pGraphicsContainer.AddElement pTextElement, 0

  pPageLayoutControl.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing

End Sub

Private Sub insertLegend_Click()

  Dim pUid As UID, pEnvelope As IEnvelope, pMapSurround As IMapSurround

  Dim m_GraphicsContainer  As IGraphicsContainer, m_MapFrame As IMapFrame

  Dim m_MapSurroundFrame As IMapSurroundFrame, m_Element As IElement, m_TrackCancel As ITrackCancel

  Set pUid = New UID

  pUid.value = "esriCarto.legend"

  Set pEnvelope = New Envelope

  pEnvelope.PutCoords 1, 1, 3.4, 2.4

  Set m_GraphicsContainer = pPageLayoutControl.PageLayout

  Set m_MapFrame = m_GraphicsContainer.FindFrame(pPageLayoutControl.ActiveView.FocusMap)

  Set m_MapSurroundFrame = m_MapFrame.CreateSurroundFrame(pUid, pMapSurround)

  Set m_MapSurroundFrame.MapFrame = m_MapFrame

  m_MapSurroundFrame.MapSurround.name = "legend"

  Set m_Element = m_MapSurroundFrame

  m_Element.Geometry = pEnvelope

  m_Element.Activate pPageLayoutControl.ActiveView.screenDisplay

  Set m_TrackCancel = New CancelTracker

  m_Element.Draw pPageLayoutControl.ActiveView.screenDisplay, m_TrackCancel

  m_GraphicsContainer.AddElement m_Element, 0

  m_Element.Geometry = pEnvelope

  pPageLayoutControl.ActiveView.PartialRefresh esriViewDrawPhase.esriViewGraphics, Nothing, Nothing

End Sub

Private Sub insertScalebar_Click()

  Dim pEnvelope As IEnvelope, pMapSurround As IMapSurround

  Dim pStyleGalleryItem As IStyleGalleryItem

  Set pEnvelope = New Envelope

  pEnvelope.PutCoords 1, 1, 3.4, 2.4

  Set pStyleGalleryItem = bgFrmShowElementStyle.getItem(esriStyleClassScaleBars)

  Set pMapSurround = CreateMapSurround(pPageLayoutControl.PageLayout, _

                      pPageLayoutControl.ActiveView.FocusMap, _

                      "ScaleBar", pEnvelope, pPageLayoutControl.ActiveView, pStyleGalleryItem)

  pPageLayoutControl.ActiveView.PartialRefresh esriViewDrawPhase.esriViewGraphics, Nothing, Nothing

End Sub

Private Sub insertNorth_Click()

  Dim pEnvelope As IEnvelope, pMapSurround As IMapSurround

  Dim pStyleGalleryItem As IStyleGalleryItem

  Set pEnvelope = New Envelope

  pEnvelope.PutCoords 0.2, 0.2, 3, 3

  Set pStyleGalleryItem = bgFrmShowElementStyle.getItem(esriStyleClassNorthArrows)

  Set pMapSurround = CreateMapSurround(pPageLayoutControl.PageLayout, _

                       pPageLayoutControl.ActiveView.FocusMap, _

                       "NorthArrow", pEnvelope, pPageLayoutControl.ActiveView, pStyleGalleryItem)

  pPageLayoutControl.ActiveView.PartialRefresh esriViewDrawPhase.esriViewGraphics, Nothing, _ Nothing

End Sub

Private Sub insertScaleText_Click()

  Dim pEnvelope As IEnvelope, pMapSurround As IMapSurround

  dim pStyleGalleryItem As IStyleGalleryItem

  Set pEnvelope = New Envelope

  pEnvelope.PutCoords 1, 1, 3.4, 2.4

  Set pStyleGalleryItem = bgFrmShowElementStyle.getItem(esriStyleClassScaleTexts)

  Set pMapSurround = CreateMapSurround(pPageLayoutControl.PageLayout, _

                        pPageLayoutControl.ActiveView.FocusMap, _

                        "ScaleText", pEnvelope, pPageLayoutControl.ActiveView, pStyleGalleryItem)

  pPageLayoutControl.ActiveView.PartialRefresh esriViewDrawPhase.esriViewGraphics, Nothing, Nothing

End Sub

Private Function CreateMapSurround(m_PageLayout As IPageLayout, m_Map As IMap, _

                          name As String, m_Envelope As IEnvelope, m_ActiveView As IActiveView, _

                          m_styleGalleryItem As IStyleGalleryItem) As IMapSurround

  Dim m_GraphicsContainer  As IGraphicsContainer, m_MapFrame As IMapFrame

  Dim m_MapSurroundFrame As IMapSurroundFrame, m_Element As IElement

  dim m_TrackCancel As ITrackCancel

  Set m_GraphicsContainer = m_PageLayout

  Set m_MapFrame = m_GraphicsContainer.FindFrame(m_Map)

  Set m_MapSurroundFrame = New MapSurroundFrame

  Set m_MapSurroundFrame.MapFrame = m_MapFrame

  Set m_MapSurroundFrame.MapSurround = m_styleGalleryItem.Item

  m_MapSurroundFrame.MapSurround.name = name

  Set m_Element = m_MapSurroundFrame

  m_Element.Geometry = m_Envelope

  m_Element.Activate m_ActiveView.screenDisplay

  Set m_TrackCancel = New CancelTracker

  m_Element.Draw m_ActiveView.screenDisplay, m_TrackCancel

  m_GraphicsContainer.AddElement m_Element, 0

  m_Element.Geometry = m_Envelope

转载于:https://www.cnblogs.com/bluemaplestudio/archive/2010/02/28/1675164.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值