📄 vba16-5.txt
字号:
Public Function PlaceDetailMapFrame() As IElement
' Position the existing detail map frame
' in the upper left corner.
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 dblFrameWidth As Double
Dim dblFrameHeight As Double
Dim pElement As IElement
Dim pEnvelope As IEnvelope
Dim pMapFrame As IMapFrame
Dim pTransform2d As ITransform2D
Dim pPoint As IPoint
Dim dblXMove As Double
Dim dblYMove As Double
' Get the page size.
Set pMxDocument = Application.Document
Set pPageLayout = pMxDocument.PageLayout
Set pActiveView = pPageLayout
Set pPage = pPageLayout.Page
pPage.QuerySize dblPageWidth, dblPageHeight
dblMargin = c_dblMargin
' Calculate the map frame's new size.
' Frame width and height are the page width
' or height less the margin and less two
' inches for other frames.
dblFrameWidth = dblPageWidth - (2 * dblMargin + 2)
dblFrameHeight = dblPageHeight - (2 * dblMargin + 2)
' Access the map frame.
Set pElement = GetMapFrameByName("DETAIL")
If pElement Is Nothing Then
MsgBox "Missing Detail map."
Set PlaceDetailMapFrame = Nothing
Exit Function
End If
' Get the map frame's current size.
Set pEnvelope = New Envelope
pElement.QueryBounds pActiveView.ScreenDisplay, _
pEnvelope
' Map frame should show the map
' at its current scale.
Set pMapFrame = pElement
pMapFrame.ExtentType = esriExtentDefault
' Resize and move the detail map frame.
Set pTransform2d = pMapFrame
Set pPoint = New Point
pPoint.X = pEnvelope.XMin
pPoint.Y = pEnvelope.YMax
With pTransform2d
.Scale pPoint, dblFrameWidth / pEnvelope.Width, _
dblFrameHeight / pEnvelope.Height
End With
dblXMove = dblMargin - pEnvelope.XMin
dblYMove = (dblPageHeight - dblMargin) - _
pEnvelope.YMax
pTransform2d.Move dblXMove, dblYMove
' Done
Set PlaceDetailMapFrame = pElement
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -