惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - GIS云中飞鹏

ArcGIS Server 9.3 REST基础教程 ArcGIS_系列视频教程::精品大放送 VS2005中删除最近打开的项目和文件的记录 [资源共享]C#+AE构建GIS桌面端应用系统框架-全代码 - GIS云中飞鹏 - 博客园 2008ESRI中国区域用户大会资料已经共享!!!^_^ 刻录机放入光盘,出现函数不正确的解决方法! ArcSDE初级教程下载 ArcIMS HTML Viewer开发经典教程:Customizing the HTML Viewer下载 “全国信息化工程师—GIS应用水平考试”考试复习资料下载! ArcObjects GIS应用开发——基于C#.NET--PDF下载 ArcGIS Unknown Spatial Reference问题解疑(转载) - GIS云中飞鹏 oracle 10g默认用户名、密码解锁 自己定制的SymbolSelectForm效果及VB.NET源码 用AE创建气泡式提示框的方法-VB.Net源码(转载) - GIS云中飞鹏 - 博客园 VS在Debug时检测到Loaderlock的解决办法 - GIS云中飞鹏 - 博客园 【ArcGIS Server 开发系列】Flyingis六大系列讲座精品PDF奉献 公司数据部培训讲义:ArcMap数字化培训教程 如何改变ArcIMS92图例字体大小中? - GIS云中飞鹏 - 博客园 在ArcGisEngine 开发中如何在Toolbar控件上添加Combobox等其他控件?
ArcGIS Engine 怎样给PageLayout替换模板
GIS云中飞鹏 · 2008-08-07 · via 博客园 - GIS云中飞鹏

                                         ArcGIS Engine 怎样给PageLayout替换模板

在打印出图时,常常需要更换已有的模板(mxt),这时数据并不改变。在ArcMap里面有一个替换模板的工具,但是在Engine里面却没有一个能直接替换模板的接口,而是需要读取新模板,取出模板里面的各个要素,然后替换掉原模板里面是相应要素。

Sub changelayout()
Dim pDoc As IMxDocument
Set pDoc = Application.Document
Dim pMap As IMap
Set pMap = pDoc.FocusMap
Dim pPageLayout As IPageLayout
Set pPageLayout = pDoc.PageLayout
'读取新模板
Dim pNewDoc As IMapDocument
Set pNewDoc = New MapDocument
pNewDoc.Open "C:Program FilesArcGISBinTemplatesLandscapeModern.mxt"
Dim pTempMap As IMap
Dim pTempPagelayout As IPageLayout
Set pTempPagelayout = pNewDoc.PageLayout
'Set pTempMap = pNewDoc.Map
Dim pTempPage As IPage
Set pTempPage = pTempPagelayout.Page

Dim pCurPage As IPage
Set pCurPage = pPageLayout.Page

'替换单位
pCurPage.Units = pTempPage.Units
'exchange page orientation
pCurPage.Orientation = pTempPage.Orientation
'替换页面尺寸
Dim dWidth As Double
Dim dHeight As Double
pTempPage.QuerySize dWidth, dHeight
pCurPage.PutCustomSize dWidth, dHeight

'删除当前Layout中除了mapframe外的所有elements
Dim pGraphicsCont As IGraphicsContainer
Dim pElement As IElement
Set pGraphicsCont = pPageLayout
pGraphicsCont.Reset
Set pElement = pGraphicsCont.Next
Do Until pElement Is Nothing
If TypeOf pElement Is IMapFrame Then
Dim pMapFrame As IMapFrame
Dim pMapFrameElement As IElement
Set pMapFrameElement = pElement
Set pMapFrame = pElement
Else
pGraphicsCont.DeleteElement pElement
pGraphicsCont.Reset
End If
Set pElement = pGraphicsCont.Next


Loop

'遍历模板的PageLayout中的所有元素,并且替换当前PageLayout中的所有元素
Dim pTempGraphicsCont As IGraphicsContainer
Set pTempGraphicsCont = pTempPagelayout
pTempGraphicsCont.Reset
Set pElement = pTempGraphicsCont.Next
Dim pArray As IArray
Set pArray = New esriSystem.Array
Do Until pElement Is Nothing
If TypeOf pElement Is IMapFrame Then
pMapFrameElement.Geometry = pElement.Geometry
Else
If TypeOf pElement Is IMapSurroundFrame Then
Dim pTempMapSurroundFrame As IMapSurroundFrame
Dim pTempMapSurround As IMapSurround
Set pTempMapSurroundFrame = pElement
Set pTempMapSurroundFrame.MapFrame = pMapFrame
Set pTempMapSurround = pTempMapSurroundFrame.MapSurround
pMap.AddMapSurround pTempMapSurround
End If
pArray.Add pElement
End If
Set pElement = pTempGraphicsCont.Next
Loop

Dim pElementCount As Long
pElementCount = pArray.Count
Dim i As Long
'将模板PageLayout中的其它元素(除了MapFrameElement和MapSurroundFrame外的元素)添加到当前PageLayout中去
For i = 0 To pElementCount - 1
pGraphicsCont.AddElement pArray.Element(pElementCount - 1 - i), 0
Next i
pDoc.ActiveView.Refresh

End Sub