Hi
I am build vb6 Context menu extension, but how to determine which popup
menu item(popupItem1 and popupItem2) was clicked?
Thanks
The code
'
' IContextMenu::QueryContextMenu
'
' In this function you must add your items
' to the context menu
'
Friend Function QueryContextMenu(ByVal hMenu As Long, ByVal indexMenu As
Long, ByVal idCmdFirst As Long, ByVal idCmdLast As Long, ByVal uFlags As
Long) As Long
Dim hSubMenu As Long, lIdx As Long
' Create a popup menu
hSubMenu = CreatePopupMenu()
' Get the file count
lIdx = UBound(m_SelectedFiles)
InsertMenu hSubMenu, lIdx, MF_BYPOSITION, idCmdFirst, "popupItem1"
InsertMenu hSubMenu, lIdx, MF_BYPOSITION, idCmdFirst, "popupItem2"
' Add the items to the context menu
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_SEPARATOR, 0, ByVal 0&
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_POPUP, hSubMenu, ByVal
"Item"
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_SEPARATOR, 0, ByVal 0&
' Return how many non separator
' menu items we were added
QueryContextMenu = UBound(m_Items) + 1
End Function
'
' Carries out the command associated with
' a context menu item.
'
Private Sub IContextMenu_InvokeCommand(lpici As shlext.CMINVOKECOMMANDINFO)
Dim Idx As Long, Verb As String, Total As Currency
On Error Resume Next
' Check if lpVerb is an string pointer
' or the ID
If (lpici.lpVerb \ &H10000) <> 0 Then
' lpVerb is a string so
' copy it from the pointer
Verb = StrFromPtrA(lpici.lpVerb)
' Search the items array for
' the command and convert
' it to the item index
For Idx = 0 To UBound(m_Items)
If m_Items(Idx).Verb = Verb Then
Exit For
End If
Next
Else
Idx = lpici.lpVerb
End If
Dim fileNames As String
' Do the action asociated
' with the menu item
Select Case Idx
Case 0
MsgBox ("popupItem1 clicked")
Case 1
MsgBox ("popupItem2 clicked")
End Select
End Sub