Unless you are already using API's to create the menu, you don't need any API's to do that - just add the items using the normal menu editor, and click the right-arrow button (so they are a level deeper than Spell Check).
Private Function make_popup_menu(ByRef myArr() As String, _
ByVal myObj As Object, _
ByVal myArrayLastRow_y0 As Integer, _
ByVal showTitleNum As Integer, _
ByVal execTitleNum As Integer) As Variant
'////////////////////////////////////////////////////
myObj.BackColor = &HC0C0FF 'red
Dim ir As Integer
Dim sID As Integer
Dim myArrayLastRow_1 As Integer
myArrayLastRow_1 = Val(myArrayLastRow_y0) + 1
ReDim Preserve myArr(UBound(myArr), myArrayLastRow_1)
sID = 5000
For ir = LBound(myArr) To UBound(myArr)
myArr(ir, myArrayLastRow_1) = "" & sID
sID = sID + 1
Next ir
'//////////////////////////////////////////////////////////
Dim hPopupMenu As Long ' handle to the popup menu to display
Dim mii As MENUITEMINFO ' describes menu items to add
Dim tpm As TPMPARAMS ' identifies the exclusion rectangle
Dim curpos As POINT_TYPE ' holds the current mouse coordinates
Dim menusel As Long ' ID of what the user selected in the popup menu
Dim FR_retval As Long ' generic return value
' Create the popup menu that will be displayed.
hPopupMenu = CreatePopupMenu()
'form additem 0,1,2,3,4,5
'//Insert Menu Open
Dim cm As Integer
For cm = LBound(myArr) To UBound(myArr)
If myArr(cm, 0) = "MFT_SEPARATOR" Or myArr(cm, 1) = "MFT_SEPARATOR" Then
' Add the second item: a separator bar.
With mii
.fType = MFT_SEPARATOR
.fState = MFS_ENABLED
.wID = myArr(cm, myArrayLastRow_1) 'number
End With
FR_retval = InsertMenuItem(hPopupMenu, cm + 1, 1, mii)
Else
' Add the second item: a separator bar.
With mii
.cbSize = Len(mii)
.fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
.fType = MFT_STRING
.wID = myArr(cm, myArrayLastRow_1) 'number
.dwTypeData = "" & myArr(cm, showTitleNum)
.cch = Len(.dwTypeData)
End With
FR_retval = InsertMenuItem(hPopupMenu, cm, 1, mii)
End If
Next cm
'//Insert Menu Closed
' Determine where the mouse cursor currently is, in order to have
' the popup menu appear at that point.
FR_retval = GetCursorPos(curpos)
' Make the exclusion rectangle empty because there's no need for it here.
With tpm
' Size of the structure.
.cbSize = Len(tpm)
' Make the exclusion rectangle empty.
FR_retval = SetRectEmpty(.rcExclude)
End With
' Display the popup menu at the mouse cursor. Instead of sending messages
' to window Form1, have the function merely return the ID of the user's selection.
menusel = TrackPopupMenuEx(hPopupMenu, TPM_TOPALIGN Or TPM_LEFTALIGN Or TPM_NONOTIFY _
Or TPM_RETURNCMD Or TPM_LEFTBUTTON, curpos.x, curpos.y, Form1.hWnd, tpm)
' Before acting upon the user's selection, destroy the popup menu now.
FR_retval = DestroyMenu(hPopupMenu)
myObj.BackColor = &H8000000F 'gray
'///////////////
'Return KEY
Dim crr As Integer
Dim nothingA As Boolean
Dim mmu_xtopic As String
Dim mmu_xtitle As String
Dim mmu_xRun As String
For crr = LBound(myArr) To UBound(myArr)
If myArr((crr), myArrayLastRow_1) = menusel Then
mmu_xtitle = "mmu_title"
mmu_xtopic = (myArr((crr), myArrayLastRow_1)) & vbCrLf & (myArr((crr), showTitleNum))
mmu_xRun = (myArr((crr), execTitleNum))
MsgBox mmu_xtitle
MsgBox mmu_xtopic
MsgBox mmu_xRun
Exit Function
End If
Next crr
Erase myArr
End Function '//make_popup_menu
I'm afraid I can't help with that, as I don't use API's to create menus - because the built-in menu editor is far simpler (and gives you events for each item too, thus more organised). One thing you will need to think about is how you are going to specify sub menus in the parameters.
Is there a particular reason that you are using API's for this?
Are the 'parent' items (Boy/Girl/Dog/Cat) known in advance?
If so there is no need for the complexity of the API's - you can just use normal menus with a single child item for each, with Index set so it is an array that can be modified as needed.
Asking my question in another way: could you create the Boy/Girl/Dog/Cat menus in the menu editor?
Ans: NO
You can see "Cmd1" Pink Color, this Command_1 is
Code:
Read .Database
return .Database Keyword to Array()
or i say my background:
I have Access .MDB file {Database}
I can doing something I need ,SQL langauge, is fine no problem.
Code:
.Acess database
SuperMarket,
Fruit,
...Brand name 1 to 10+
Drink,
...Brand name 1 to 10+
Rice,
...Brand name 1 to 10+
Oil , maybe +50 items
Now, I need changed to Menu Style
that {Main Classification} in .MDB ,
I can read that Key to Array{} MAIN, But I no sure how many total item list!
that {Sub Class} in .MDB. When
When "Main" Class found, get SubItem List,
When SubItem _List _Click,
doing something...
In that case if you want to use menus you will need to use API's... and as I said earlier, I can't help with that.
A much simpler alternative would be to use controls (perhaps listboxes) for it, filling the first based on the data, then the second based on the users selection.
If you don't have enough space on your form, you could use a separate form for those controls.