简体   繁体   English

VB.NET:如何获取从资源 Dll 加载的 MenuID

[英]VB.NET: How to Take MenuIDs those Loaded From Resource Dll

I have mainMenu at my own Resource-DLL and I put that to my Windows Form As MainMenu by API Methods: (LoadMenu and SetMenu)我在我自己的资源 DLL 中有 mainMenu,我通过 API 方法将其作为 MainMenu 放入我的 Windows 中:(LoadMenu 和 SetMenu)

How can I take MenuIDs After Clicking with WndProc?使用 WndProc 单击后如何获取 MenuID?

 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.此语句给出的 ID 为错误。


Hi there, I find a way for take different value of each menu item selection by wParam:您好,我找到了一种通过 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.因此,通过此更改可以在单击 menuItem 后拥有一个 ID,但这不是资源 DLL 中的真实 ID。

How Can I take the True ID of Clicked MenuItem?!!!我怎样才能获取点击的菜单项的真实 ID?!!!

Use this Code to Get MenuItem ID:使用此代码获取 MenuItem ID:

MenuID = (m.WParam.ToInt64 And &HFFFF&)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM