Here's a sample to get you started - An old class I created for adding pop up menus to any windows forms item. I used the class utility wizard in vb6. The winapi code might look intimidating but you can get the idea for adding properties, methods and funtions to your objects:
Option Explicit
' cPopMenu class
' Simple API class to create and track popup menus on forms or controls
' C. Hatcher
' 2/17/04
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Public Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function CreatePopupMenu Lib _
"user32" () As Long
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Private Declare Function TrackPopupMenuEx Lib "user32" _
(ByVal hMenu As Long, ByVal un As Long, _
ByVal n1 As Long, ByVal n2 As Long, _
ByVal hWnd As Long, lpTPMParams As Any) As Long
Private Declare Function InsertMenuItem Lib "user32" _
Alias "InsertMenuItemA" (ByVal hMenu As Long, _
ByVal un As Long, ByVal bool As Long, _
lpcMenuItemInfo As MENUITEMINFO) As Long
Private Declare Function DestroyMenu Lib "user32" _
(ByVal hMenu As Long) As Long
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Const MF_STRING = &H0&
Private Const TPM_RETURNCMD = &H100&
Private Const MIIM_ID = &H2
Private Const MIIM_TYPE = &H10
Private Const MIIM_DATA = &H20
Private m_lngMnu As Long
Private m_lngID As Long
Private m_PT As POINTAPI
Private m_objMNU As MENUITEMINFO
'local variable(s) to hold property value(s)
Private mvarmnuName As String 'local copy
'local variable(s) to hold property value(s)
Private mvarItemCount As Integer 'local copy
'local variable(s) to hold property value(s)
Private mvarFirstItem As Integer 'local copy
Public Property Get FirstItem() As Integer
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.FirstItem
FirstItem = mvarFirstItem
End Property
Public Property Get ItemCount() As Integer
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.ItemCount
ItemCount = mvarItemCount
End Property
Public Property Get mnuName() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.mnuName
mnuName = mvarmnuName
End Property
Public Property Let mnuName(sName As String)
mvarmnuName = mnuName
End Property
' a public function to get the current position of the mouse
Public Function GetCursorPosition(lpPointIn As POINTAPI) As Long
GetCursorPosition = GetCursorPos(lpPointIn)
m_PT = lpPointIn
End Function
Public Function CreateSingleMenu(insName As String) As Long
m_lngMnu = CreatePopupMenu()
Dim lCount As Long
Dim inStrNames(1 To 1) As String
inStrNames(1) = insName
mvarItemCount = UBound(inStrNames)
mvarFirstItem = LBound(inStrNames)
For lCount = mvarFirstItem To mvarItemCount
With m_objMNU
.cbSize = Len(m_objMNU)
.fMask = MIIM_TYPE Or MIIM_ID Or MIIM_DATA
.dwTypeData = inStrNames(lCount)
.cch = Len(inStrNames(lCount))
.fType = MF_STRING
.wID = lCount
End With
Call InsertMenuItem(m_lngMnu, lCount, 1, m_objMNU)
Next lCount
End Function
Public Function CreateMenu(inStrNames() As String) As Long
m_lngMnu = CreatePopupMenu()
Dim lCount As Long
mvarItemCount = UBound(inStrNames)
mvarFirstItem = LBound(inStrNames)
For lCount = mvarFirstItem To mvarItemCount
With m_objMNU
.cbSize = Len(m_objMNU)
.fMask = MIIM_TYPE Or MIIM_ID Or MIIM_DATA
.dwTypeData = inStrNames(lCount)
.cch = Len(inStrNames(lCount))
.fType = MF_STRING
.wID = lCount
End With
Call InsertMenuItem(m_lngMnu, lCount, 1, m_objMNU)
Next lCount
End Function
Public Function TrackMenu(ByVal x As Long, ByVal y As Long, ByVal lngHwnd As Long) As Long
TrackMenu = TrackPopupMenuEx(m_lngMnu, TPM_RETURNCMD, x, y, lngHwnd, ByVal 0&)
End Function