当前位置:甜馍馍地理信息网 >> 地理信息系统GIS >> 产品教程 >> 正文 >>  [阅读资讯:ArcMAP中如何使用状态条StatusBar与进度条ProgressBar[代码]]

ArcMAP中如何使用状态条StatusBar与进度条ProgressBar[代码]

[ 来源:互联网 | 时间:2007年09月15日 | 收藏本文 ] 【

一般情况下,通过ArcMAP的Application实例获取IstatusBar的实例,然后再通过StatusBar获取IprogressBar的实例,并将IprogressBar的实例赋给IstepProgressor类型的变量。

本例要演示的是如何使用状态条(StatusBar)与进度条(ProgressBar)。实现后的结果为在ArcMap中,状态条位于其底部,它显示ArcMAP当前状态的信息,包含进度条。

l   程序说明

运行函数ShowProgress将在ArcMap的下方添加一个状态条(StatusBar)和进度条(ProgressBar)。

l   代码

Sub ShowProgress()
On Error GoTo err1
Dim pDocument As IMxDocument
Dim pMap As IMap
Dim pLayer As ILayer
Dim pFeatureLayer As IFeatureLayer
Dim pFeatureCursor As IFeatureCursor
Dim pFeatureClass As IFeatureClass
Dim pFeature As IFeature
Dim dSum As Double
Dim lFieldIndex As Long
Dim lNumFeat As Long
Dim dInterval As Double
Set pDocument = Application.Document
Set pMap = pDocument.FocusMap
Set pLayer = pMap.Layer(0)
Set pFeatureLayer = pLayer
Set pFeatureClass = pFeatureLayer.FeatureClass
Set pFeatureCursor = pFeatureLayer.Search(Nothing, True)
Dim pStatusBar As IStatusBar
Set pStatusBar = Application.StatusBar
Dim pStepProgressor As IStepProgressor
Set pStepProgressor= pStatusBar.ProgressBar
lNumFeat = pFeatureClass.FeatureCount(Nothing)
dInterval = lNumFeat / 100
Set pFeature = pFeatureCursor.NextFeature
' 字段名"FID"用户根据实际而改变
lFieldIndex = pFeature.Fields.FindField("FID")
Dim PauseTime, Start, Finish, TotalTime, i
PauseTime = 0.5
pStepProgressor.MinRange = 1
pStepProgressor.MaxRange = lNumFeat
pStepProgressor.StepValue = dInterval
For i = 1 To lNumFeat
dSum = dSum + pFeature.Value(lFieldIndex)
Set pFeature = Nothing
Set pFeature = pFeatureCursor.NextFeature
pStepProgressor.Position = i
pStepProgressor.Message = "Reading record " & Str(i) & ". Sum =" & Str(dSum)
pStepProgressor.Step
pStepProgressor.Show
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Next
pStepProgressor.Hide
Exit Sub
err1:
  MsgBox Err.Description
End Sub

【推荐本文】 【打印本页】 【返回顶部
最新文章
推荐文章