📄 vba16-10.txt
字号:
Private Sub AddNorthArrow(pElement As IElement)
' Add a north arrow for the
' given map frame.
Dim pMxDocument As IMxDocument
Dim pPageLayout As IPageLayout
Dim pPage As IPage
Dim pActiveView As IActiveView
Dim dblPageWidth As Double
Dim dblPageHeight As Double
Dim dblMargin As Double
Dim pID As New UID
Dim pMapSurround As IMapSurround
Dim dblFrameWidth As Double
Dim dblFrameHeight As Double
Dim pMapFrame As IMapFrame
Dim pMapSurroundFrame As IMapSurroundFrame
Dim pNorthArrowElement As IElement
Dim pEnvelope As IEnvelope
Dim pFrameElement As IFrameElement
Dim pGraphicsContainer As IGraphicsContainer
Dim dblX As Double
Dim dblY As Double
' Get the page size.
Set pMxDocument = Application.Document
Set pPageLayout = pMxDocument.PageLayout
Set pActiveView = pPageLayout
Set pGraphicsContainer = pPageLayout
Set pPage = pPageLayout.Page
pPage.QuerySize dblPageWidth, dblPageHeight
dblMargin = c_dblMargin
' North arrow frame width and _
' height are 2 inches.
dblFrameWidth = 2
dblFrameHeight = 2
' Create a north arrow map surround.
Set pMapFrame = pElement
pID.Value = "esriCore.MarkerNorthArrow"
Set pMapSurround = New MarkerNorthArrow
Set pMapSurroundFrame = pMapFrame. _
CreateSurroundFrame(pID, pMapSurround)
' Size and position the north arrow frame.
Set pFrameElement = pMapSurroundFrame
Set pNorthArrowElement = pFrameElement
Set pEnvelope = New Envelope
' X and Y of the upper left corner.
dblX = dblPageWidth - (dblMargin + dblFrameWidth)
dblY = dblMargin + dblFrameHeight
pEnvelope.PutCoords dblX, (dblY - dblFrameHeight), _
(dblX + dblFrameWidth), dblY
' Draw a rectangle on the page layout.
AddRectangle pEnvelope
' scale down the rectangle to
' fit the north arrow.
pEnvelope.Expand 0.9, 0.9, True
pNorthArrowElement.Geometry = pEnvelope
' Draw the north arrow on the page layout.
pNorthArrowElement.Activate pActiveView.ScreenDisplay
pGraphicsContainer.AddElement pNorthArrowElement, 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -