Question How to Take MenuIDs those Loaded From Resource Dll

vbloverprogrammer

New member
Joined
Nov 25, 2022
Messages
4
Programming Experience
5-10
I have mainMenu at my own Resource-DLL and I put that to my Windows Form As MainMenu by API Methods: (LoadMenu and SetMenu)

How can I take MenuIDs After Clicking with WndProc?

Tried Code:
 Protected Overrides Sub WndProc(ByRef m As Message)
        If m.Msg = &H11F And m.LParam <> HMainMenu Then
            If m.LParam <> 0 Then
                MenuID = GetMenuItemID(m.LParam, 0)
                Me.ListBox1.Items.Add("Selected.")
            Else
                Me.ListBox1.Items.Add("Clicked. " & MenuID.ToString)
            End If
        End If
        MyBase.WndProc(m)
    End Sub
This statement give the ID as Wrong.
 

vbloverprogrammer

New member
Joined
Nov 25, 2022
Messages
4
Programming Experience
5-10
I have mainMenu at my own Resource-DLL and I put that to my Windows Form As MainMenu by API Methods: (LoadMenu and SetMenu)

How can I take MenuIDs After Clicking with WndProc?

Tried Code:
 Protected Overrides Sub WndProc(ByRef m As Message)
        If m.Msg = &H11F And m.LParam <> HMainMenu Then
            If m.LParam <> 0 Then
                MenuID = GetMenuItemID(m.LParam, 0)
                Me.ListBox1.Items.Add("Selected.")
            Else
                Me.ListBox1.Items.Add("Clicked. " & MenuID.ToString)
            End If
        End If
        MyBase.WndProc(m)
    End Sub
This statement give the ID as Wrong.
Hi there,
I find a way for take different value of each menu item selection by wParam:
Tried Code:
 Protected Overrides Sub WndProc(ByRef m As Message)
        If m.Msg = &H11F And m.LParam <> HMainMenu Then
            If m.LParam <> 0 Then
                MenuID =(m.WParam.ToInt64 And 255)
                Me.ListBox1.Items.Add("Selected.")
            Else
                Me.ListBox1.Items.Add("Clicked. " & MenuID.ToString)
            End If
        End If
        MyBase.WndProc(m)
    End Sub

So with this changes Can have an ID after menuItem clicked But that's not a True ID at Resource DLL.

How Can I take the True ID of the Clicked MenuItem?!!!
 
Last edited:
Top