Why do I not receive the WM_MENUCHAR message?

I implemented an IContextMenu3 interface and I am trying to capture keystrokes for my own custom accelerator. The problem is that if i hover over my submenu in the root menu I dont get any WM_MENUCHAR messages whereas if I hover over a submenu that is inside one of my submenu's then I do.

I know that the WM_INITMENUPOPUP message only gets sent if there is a child. The WM_MENUCHARhas the caveat that no accelerators are bound to the key. I know this caveat to be held since when I press a key, I get the distinctive 'no-accelerator' beep.

Is there another caveat that I am not aware of?

This is the smallest code I can get that reproduces the problem:

HRESULT CFolderViewImplContextMenu::QueryContextMenu(HMENU hmenu, UINT uMenuIndex, UINT idCmdFirst, UINT idCmdLast, UINT /* uFlags */)
UINT uID = idCmdFirst;
HMENU hSubmenu = CreatePopupMenu();

MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(MENUITEMINFO);
mii.dwTypeData = str_toWchar("test");
mii.wID = uID++;
mii.hSubMenu = hSubmenu;    

InsertMenuItem ( hmenu, 0, TRUE, &mii );
InsertMenu ( hSubmenu, 0, MF_BYPOSITION, uID++, L"&Notepad" );
InsertMenu ( hSubmenu, 1, MF_BYPOSITION , uID++, L"&Internet Explorer" );

HMENU hSubmenu2 = CreatePopupMenu();
MENUITEMINFO mii2 = {0};
mii2.cbSize = sizeof(MENUITEMINFO);

mii2.fType  = MFT_OWNERDRAW;
mii2.wID    = uID++;
mii2.hSubMenu = hSubmenu2;
InsertMenuItem ( hSubmenu, 0, TRUE, &mii2 );

InsertMenuA ( hSubmenu2, 0, MF_BYPOSITION, uID++, "");



WM_MENUCHAR is forwarded only for submenus. (It can't be forwarded for top-level menu items because that would be a Catch-22. You want to forward it to the context menu handler for the menu item that the the key corresponds to, but you can't do that until you have the answer to WM_MENUCHAR!)

Need Your Help

Is there a limit of elements that could be stored in a List?

c# .net collections ilist

Is there a limit of elements that could be stored in a List ? or you can just keeping adding elements untill you are out of memory ?

Bootstrap not switching back and forth repeatedly between the same tabs

javascript jquery html

Recently I've come across this (http://bootsnipp.com/snippets/featured/e-mail-interface) snippet and as I started to experiment with it I noticed that there is some odd behaviour regarding switchin...