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?
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:
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 Clicked MenuItem?!!!
CodePudding user response:
Use this Code to Get MenuItem ID:
MenuID = (m.WParam.ToInt64 And &HFFFF&)