Hello all,
This should be simple... I am converting VBA customization to VB .NET in VS 2008 Express Edition.
In VBA i have a custom selection tool. Aside from just selecting, when a Mouse_Down receives Button = 2 parameter (right click) a popup a context menu with some items that call various other procedures.
I need some help with making this work in .Net...
I used the .NET sample to get the feel for this and i am sure i can re-create the select tool but i am having problems with the context menu.
Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
Dim pLayer As ILayer
Dim pContextMenu As ICommandBar
Dim pAppPosition As IWindowPosition
Dim pPoint As POINTAPI
If pMxDoc.SelectedLayer Is Nothing Then
MsgBox "Select a layer in the TOC!": GoTo ep
End If
Select Case button
Case 1
Set pLayer = pMxDoc.SelectedLayer
If pLayer Is Nothing Then
MsgBox "You must select 1 feature layer in the TOC!": GoTo ep
End If
If Not TypeOf pLayer Is IGeoFeatureLayer Then
MsgBox "You must select 1 feature layer in the TOC!": GoTo ep
End If
Set m_pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)
m_bIsMouseDown = True
Case 2
'on right click = popup
Set pContextMenu = CommandBars.Create("Go2Grid", esriCmdBarTypeShortcutMenu)
Set pAppPosition = Application
' Add 3 built in commands to the new context menu using the built in ArcID module.
' pContextMenu.CreateMacroItem "Sketch Tool", 27, "Normal.ThisDocument.SetSketchTool"
pContextMenu.CreateMacroItem "New Feature Class", 8, "Normal.Module1.CreateNewFeatureClass"
pContextMenu.CreateMacroItem "Delete Layer", 13, "Normal.Module1.DeleteFeatureClass"
pContextMenu.CreateMacroItem "Copy To...", 20, "Normal.ThisDocument.CopyFeatures"
pContextMenu.CreateMacroItem "Draws Around...", 26, "Normal.ThisDocument.DrawsAroundFeatures"
pContextMenu.CreateMacroItem "Clear Tool", 10, "Normal.ThisDocument.ClearCurrentTool"
pContextMenu.CreateMacroItem "Delete Features", 13, "Normal.Module1.DeleteFeatures"
' Popup the menu.
pPoint.x = x
pPoint.y = y
ClientToScreen pActiveView.ScreenDisplay.hwnd, pPoint
pContextMenu.Popup pPoint.x, pPoint.y
Case Else
GoTo ep
End Select
End Sub