You simply create another menu and add it as a submenu. You can do this by calling the same function as AppendMenu , you just need to set uFlags on MF_POPUP and pass the handle to the submenu as a uIDNewItem .
For example, something like:
case WM_CREATE: HMENU hMenubar = CreateMenu(); HMENU hMenu = CreateMenu(); HMENU hSubMenu = CreatePopupMenu(); AppendMenu(hMenubar, MF_POPUP, (UINT_PTR)hMenu, "Menu"); AppendMenu(hMenu, MF_STRING, ID_SM, "Sub Menu"); AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu, "Sub-Sub Menu"); SetMenu(hwnd, hMenubar); break; ) hMenu, "Menu"); case WM_CREATE: HMENU hMenubar = CreateMenu(); HMENU hMenu = CreateMenu(); HMENU hSubMenu = CreatePopupMenu(); AppendMenu(hMenubar, MF_POPUP, (UINT_PTR)hMenu, "Menu"); AppendMenu(hMenu, MF_STRING, ID_SM, "Sub Menu"); AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu, "Sub-Sub Menu"); SetMenu(hwnd, hMenubar); break; (UINT_PTR) hSubMenu, "Sub-Sub Menu"); case WM_CREATE: HMENU hMenubar = CreateMenu(); HMENU hMenu = CreateMenu(); HMENU hSubMenu = CreatePopupMenu(); AppendMenu(hMenubar, MF_POPUP, (UINT_PTR)hMenu, "Menu"); AppendMenu(hMenu, MF_STRING, ID_SM, "Sub Menu"); AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu, "Sub-Sub Menu"); SetMenu(hwnd, hMenubar); break;
You do not need to do anything in response to WM_COMMAND . A window automatically displays a pop-up menu when you hover over a parent menu item. Of course, you will need to process the commands of the elements displayed in the submenu.