[COLOR=Sienna]How to Popup a Menu for the Menu created by MenuEditor & populated at runtime, the Popup should be shown when the user right click the Menu.[/COLOR]
Hi,

I need to show the PopuMenu for populated Menu, either its created by API as below or by MenuObject. The below
is the way i created the Menu through API based on the sample of ROB in this Forum.

The below is the code in the General Declaration Section in the Form.
PHP Code:
Const MF_CHECKED = &H8&
Const 
MF_APPEND = &H100&
Const 
TPM_LEFTALIGN = &H0&
Const 
MF_DISABLED = &H2&
Const 
MF_GRAYED = &H1&
Const 
MF_SEPARATOR = &H800&
Const 
MF_STRING = &H0&
Private 
Type POINTAPI
    X 
As Long
    Y 
As Long
End Type
Private Declare Function CreatePopupMenu Lib "user32" () As Long
Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As LongByVal wFlags As LongByVal X As LongByVal Y As LongByVal nReserved As LongByVal hwnd As LongByVal lprc As Any) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As LongByVal bRevert As Long) As Long
Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As LongByVal wFlags As LongByVal wIDNewItem As LongByVal lpNewItem As Any) As Long
Private Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim hMenu 
As Long

Private Type MSG
    hwnd 
As Long
    message 
As Long
    wParam 
As Long
    lParam 
As Long
    time 
As Long
    pt 
As POINTAPI
End Type 
I am using a Grid control, that is populated at runtime with AreaName, In that GridControl's MouseUp Event, I
am loading the Equipment for the Cicked Area is populated and displayed in a Menu and shown to the user. By using
the below code. It works fine. All Equipments are added to the Menu created by the Menu Editor at runtime.

PHP Code:
Private Sub JanfpSpr_MouseUp(Button As IntegerShift As IntegerAs SingleAs Single)
    
Dim CurSprVal As Variant
    Dim DtVal 
As Variant
    Dim oMenu 
As Menu
    Dim rstSi 
As New ADODB.Recordset
    Dim ShtType 
As String
    Dim JanCritTyp 
As Variant
    
    
If Button vbLeftButton Then
        JanfpSpr
.GetText 4JanfpSpr.ActiveRowJanCritTyp
        JanfpSpr
.GetText 1JanfpSpr.ActiveRowCurSprVal
        JanfpSpr
.GetText 3JanfpSpr.ActiveRowDtVal
        
        ShtType 
Mid(CurSprValLen(CurSprVal) - 4Len(CurSprVal))
        
CurSprVal Mid(CurSprVal1Len(CurSprVal) - 9)
        
        If 
JanCritTyp "Area" Then
                SQL 
"select * from EquipMaster where ArName='" Mid(CurSprVal7Len(CurSprVal)) & "' And Nextti Between #" DtVal "# And #" DtVal "# And ShtTp='" ShtType "' order by ENo"
                
If rstSi.State 1 Then rstSi.Close
                rstSi
.Open SQLcnnNewadOpenStaticadLockReadOnlyadCmdText
                Call UnloadMenuItems
                mnuLstSubItms
(0).Caption Mid(CurSprVal7Len(CurSprVal))
                
mnuLstSubItms(0).Enabled False
            
                
While Not rstSi.EOF
                    Load mnuLstSubItms
(mnuLstSubItms.Count 1)
                    
mnuLstSubItms(mnuLstSubItms.UBound).Caption rstSi.Fields("ENo")
                    
mnuLstSubItms(mnuLstSubItms.UBound).Enabled True
                    rstSi
.MoveNext
                Wend
                mnuLstEqp
.Enabled True
                Call PopupMenu
(mnuInfo)
        ElseIf 
JanCritTyp "Equipment" Then
               Call UnloadMenuItems
               mnuLstEqp
.Enabled False
               Call PopupMenu
(mnuInfo)
        
End If
    
End If
'    End If
End Sub 
Just in the Above code I added the Equipment Names in the Menu, If the User Right Click any
1 of the Equipment from the Menu then i need to show a Popup Menu with Update,Report etc.
for this Popup from the Equipment I added the Below Code in Form_Load() and mnuLstSubItms_Click()
PHP Code:
Private Sub Form_Load()
    
hMenu CreatePopupMenu()
    
AppendMenu hMenuMF_STRINGByVal 0&, "&Update"
        
AppendMenu hMenuMF_SEPARATORByVal 0&, ByVal 0&
        
AppendMenu hMenuMF_STRINGByVal 0&, "&Delete"
        
AppendMenu hMenuMF_SEPARATORByVal 0&, ByVal 0&
        
AppendMenu hMenuMF_STRINGByVal 0&, "&Report"
End Sub

Private Sub mnuLstSubItms_Click(Index As Integer)
    
Dim pt As POINTAPI
    GetCursorPos pt
    TrackPopupMenu hMenu
TPM_LEFTALIGNpt.Xpt.Y0Me.hwndByVal 0&
End Sub 
What happens for this code is, The Popup menu is Show, but as soon as this Popup Menu is shown
the existing PopuMenu disappears, i need both to be visible as we can see in Windows Menus

[B]Requirements:[/B]

How to find which MouseButton is Clicked in the mnuLstSubItms_Click Event.
How to and where to write the Events for the PopupMenu created through API (for Menu Update,Report)
How to protect without the Menu disappears, when the user right click the Equipment.

As (Moderator) Rob said i posted here this issue in the New Thread. Hope any VBForums member
might have faced the same scenario. Kindly check this and reply me.

The picture of the Menus on runtime and design time are also attached here for your reference.

Thankyou,
Chock.