Given a menu object in VB, I'd like to determine the accelerator key (shortcut), if any, that the menu object uses.

For every menu command on my form in my (VB5) OCX, I need to call my own saveState routine exactly once. I can subclass the form's Window Proc testing for WM_COMMAND and lParam=0 and the high word of wParam being 0 (which indicates a menu command being invoked). The low word of wParam then contains the (1 based) menu "number" for the selected menu command. However, if the menu command is invoked via an accelerator (Ctrl+acceleratorKey) then no WM_COMMAND is sent. For these situations, I will put the call to saveState directly in the menu command (..._Click event), but then I should bypass the call in the subclassed form's Window Proc.

That's why I want to determine the accelerators on my menus programatically (but it's an interesting question anyway).

Starter code:

idx = 0
Set dctMenus = New Dictionary
For each ctrl in myForm.Controls
If Typename(ctrl) = "Menu" Then
idx = idx + 1
dctMenus.Add idx, Array(ctrl, "accelerator key information goes here")
End If