我在程序中想删除原来在ArcMap中生成的比例尺等地图修饰元素,但是总是报错,程序就崩溃了……(pGraphContainer.DeleteElement pElement)
后来我改一下测试的代码如下,错是不会报了,但是结果比例尺删的只剩一个单位“米”了,我又改变了一下元素的大小,已经删除的比例尺标注,横线又回来了,等于没删
帮忙啊,搞了几天了
Do While Not pElement Is Nothing
If TypeOf pElement Is MapSurroundFrame Then '如果是地图修饰
Dim pElementPro As IElementProperties2
Set pElementPro = pElement
10
Dim pMapSurroundFrame As IMapSurroundFrame
Dim pGraphicsComposite As IGraphicsComposite
Dim pEnumEle As IEnumElement, pEle As IElement
Set pMapSurroundFrame = pElement
Set pGraphicsComposite = pMapSurroundFrame
Set pEnumEle = pGraphicsComposite.Graphics(GetActiveView.ScreenDisplay, Nothing) '?图形化拆分元素
pEnumEle.Reset
Set pEle = pEnumEle.Next
20
Do Until pEle Is Nothing
If TypeOf pEle Is GroupElement Then
Dim pGroupEle As IGroupElement '组元素
Set pGroupEle = pEle
pGroupEle.ClearElements
30
Else
pGraphContainer.DeleteElement pEle '一般元素
End If
Set pEle = pEnumEle.Next
Loop
End If
40
[此贴子已经被作者于2006-4-17 20:14:40编辑过]