waterblue
路人甲
路人甲
  • 注册日期2004-09-02
  • 发帖数72
  • QQ
  • 铜币387枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1381回复:1

加载和保存当前MapControl中的视图?

楼主#
更多 发布于:2005-05-08 16:01
<P>以下代码只能实现保存当前pagelayout中的内容,</P>
<P>请问:怎么样实现保存mapcontrol中的内容</P>
<P>我分析的原因是:frmMap.MapMain.LoadMxFile sFilePath,而pagelayout中的内容是</P>
<P>Set frmMap.MainLayout.PageLayout = m_pMapDocument.PageLayout</P>
<P>通过接口IMapDocument实现,所以现在的方法是怎么样通过IMapDocument接口加载到MapMain中</P>
<P>这种方法有问题:Set frmMap.MapMain.Map=m_pMapDocument.Map(0)</P>
<P>请问有谁知道其他的方法,告知感谢!</P>
<P>MapMain为Mapcontrol控件</P>
<P>MapLayout为PageLayout控件</P>
<P>Private m_pMapDocument As IMapDocument</P>
<P>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</P>
<P>
    '验证并载入MXD文件
    If frmMap.MapMain.CheckMxFile(sFilePath) Then</P>
<P>
        frmMap.MapMain.MousePointer = esriPointerHourglass
        m_pMapDocument.Open sFilePath</P>
<P>        Set frmMap.MainLayout.PageLayout = m_pMapDocument.PageLayout

        frmMap.MapMain.LoadMxFile sFilePath
</P>
<P>        '保持map上的视图区域与doc上的一致
      
        Dim pActiveView As IActiveView
        Set pActiveView = frmMap.MapMain.ActiveView
        Set pActiveView = m_pMapDocument.ActiveView</P>
<P>'
        frmMap.MapMain.MousePointer = esriPointerDefault
        
    Else
        MsgBox sFilePath ; " 不是有效的文件"
    End If
End Sub</P>
<P>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
</P>
喜欢0 评分0
http://www.geostar.com.cn(吉奥 公司) http://www.waterblue.com.cn(水之灵,蓝之静 个人)
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15945
  • QQ554730525
  • 铜币25337枚
  • 威望15352点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2005-05-08 18:15
调用toolbarcontrol的命令也ok的
举报 回复(0) 喜欢(0)     评分
游客

返回顶部