阅读:1567回复:1
加载和保存当前MapControl中的视图?以下代码只能实现保存当前pagelayout中的内容, 请问:怎么样实现保存mapcontrol中的内容 我分析的原因是:frmMap.MapMain.LoadMxFile sFilePath,而pagelayout中的内容是 Set frmMap.MainLayout.PageLayout = m_pMapDocument.PageLayout 通过接口IMapDocument实现,所以现在的方法是怎么样通过IMapDocument接口加载到MapMain中 这种方法有问题:Set frmMap.MapMain.Map=m_pMapDocument.Map(0) 请问有谁知道其他的方法,告知感谢! MapMain为Mapcontrol控件 MapLayout为PageLayout控件 Private m_pMapDocument As IMapDocument Private Sub OpenDoc() CommonDialog1.DialogTitle = "浏览Map文档" CommonDialog1.Filter = "Map Documents (*.mxd)|*.mxd" CommonDialog1.ShowOpen Dim sFilePath As String sFilePath = CommonDialog1.FileName If sFilePath = "" Then Exit Sub Set m_pMapDocument = New MapDocument '验证并载入MXD文件 If frmMap.MapMain.CheckMxFile(sFilePath) Then frmMap.MapMain.MousePointer = esriPointerHourglass m_pMapDocument.Open sFilePath Set frmMap.MainLayout.PageLayout = m_pMapDocument.PageLayout frmMap.MapMain.LoadMxFile sFilePath '保持map上的视图区域与doc上的一致 Dim pActiveView As IActiveView Set pActiveView = frmMap.MapMain.ActiveView Set pActiveView = m_pMapDocument.ActiveView ' frmMap.MapMain.MousePointer = esriPointerDefault Else MsgBox sFilePath ; " 不是有效的文件" End If End Sub Private Sub SaveDoc() '判断只读的情况 If m_pMapDocument.IsReadOnly(m_pMapDocument.DocumentFilename) = True Then MsgBox "This map document is read only!", , "Save Failed" Exit Sub End If '存盘 m_pMapDocument.Save m_pMapDocument.UsesRelativePaths MsgBox "存盘成功!", , "Saved Document" End Sub |
|
|
1楼#
发布于:2005-05-08 18:15
调用toolbarcontrol的命令也ok的
|
|
|