Monthly Archives: October 2011

Event Handler

Friend Sub AddHandlerEx()

Dim application2 As ESRI.ArcGIS.Framework.IApplication = CType(My.ThisApplication, ESRI.ArcGIS.Framework.IApplication)
Dim mxDocument As ESRI.ArcGIS.ArcMapUI.IMxDocument = application2.Document
Dim activeView As ESRI.ArcGIS.Carto.IActiveView = mxDocument.ActiveView
Dim map As ESRI.ArcGIS.Carto.IMap = activeView.FocusMap
‘Step 2: Create an instance of the delegate using the AddressOf operator and add it to
‘the AfterDraw event.
m_ActiveViewEventsSelectionChanged = New ESRI.ArcGIS.Carto.IActiveViewEvents_SelectionChangedEventHandler(AddressOf OnActiveViewEventsSelectionChanged)
‘Step 3: Dynamically associate an event handler to the delegate object.
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).SelectionChanged, m_ActiveViewEventsSelectionChanged

End Sub

Public Sub RemoveHandlerEx()
Dim application2 As ESRI.ArcGIS.Framework.IApplication = CType(My.ThisApplication, ESRI.ArcGIS.Framework.IApplication)
Dim mxDocument As ESRI.ArcGIS.ArcMapUI.IMxDocument = application2.Document
Dim activeView As ESRI.ArcGIS.Carto.IActiveView = mxDocument.ActiveView
Dim map As ESRI.ArcGIS.Carto.IMap = activeView.FocusMap
‘Step 4: Dynamically remove an event handler.
RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).SelectionChanged, m_ActiveViewEventsSelectionChanged
End Sub

Advertisements

modProgBar

modProgBar

Option Explicit On

Imports System.Windows.Forms

Module modProgBar

Public theProgBar As ProgressBar
Public theProgBarTitle As Label
Public theProgBarTitleMsg As String
Public theCallBtn As Button
Public theCallBtn2 As Button

Public Sub InitProgressBar(ByVal progMsg As String)
theProgBar.Minimum = 0
theProgBar.Maximum = 100
theProgBarTitleMsg = progMsg
theProgBarTitle.Text = progMsg & ” …”
theProgBar.Enabled = True
theProgBarTitle.Enabled = True
theCallBtn.Enabled = False
theCallBtn2.Enabled = False
End Sub

Public Sub StepProgressBar(ByVal thisNum As Long, ByVal totalNum As Long)
Dim currentPercent As Integer
‘currentPercent = Int((thisNum / totalNum) * 100)
currentPercent = modCommon.GetCeiling((thisNum / totalNum) * 100)
theProgBar.Value = currentPercent
theProgBarTitle.Text = theProgBarTitleMsg & ” (” & CStr(currentPercent) & “%) …”
System.Windows.Forms.Application.DoEvents()
End Sub

Public Sub EndProgressDialog(Optional ByVal isStep As Boolean = False)
theProgBar.Value = 0
IIf(isStep, theProgBarTitle.Text = AppName & ” – Step Done!”, theProgBarTitle.Text = AppName & ” – Task Done!”)
theProgBar.Enabled = False
theProgBarTitle.Enabled = False
theCallBtn.Enabled = True
theCallBtn2.Enabled = True
End Sub

End Module

button

With F
theProgBar = .progBar : theProgBar.Enabled = False
theProgBarTitle = .labProgTitle : theProgBarTitle.Text = “” : theProgBarTitle.Enabled = False
theCallBtn = .cmdOK
theCallBtn2 = .cmdCancel

.ShowDialog()

End With

module

Dim runflag As Long
runflag = 0 : modProgBar.InitProgressBar(“Exporting : “)

Do While Blah
runflag = runflag + 1 : modProgBar.StepProgressBar(runflag, Count)
Loop

modProgBar.EndProgressDialog()

Check if folder exists

Dim fs
fs = CreateObject(“Scripting.FileSystemObject”)
If fs.FolderExists(Me.txtFolder.Text) Then
modExcel.Export(Me.txtFolder.Text)
End If