I`m trying to create a menu programmatically but the code below fails to create the popup menu in the second menu item (neighbor of file)(in first File->new etc. everything is fine).
When I click on View it does nothing instead of show SelectAll command.
HMENU menu = CreateMenu();
HMENU subMenu1 = CreatePopupMenu();
AppendMenu(subMenu1,MF_STRING,IDC_MENU_NEW,_T("New"));
AppendMenu(subMenu1,MF_STRING,IDC_MENU_EXIT,_T("Exit"));
AppendMenu(menu,MF_POPUP,(UINT_PTR)subMenu1,_T("File"));
SetMenu(dlg,menu);
HMENU menu2 = CreateMenu();
HMENU subMenu2 = CreatePopupMenu();
AppendMenu(menu,MF_INSERT,(UINT_PTR)menu2,_T("View"));
AppendMenu(subMenu2,MF_STRING,IDC_MENU_EXIT2,_T("Select All"));
AppendMenu(menu2,MF_POPUP,(UINT_PTR)subMenu2,_T("View"));
What am I doing wrong? Can you point me to somewhere to find the information?
I believe your error is on this line of code
MF_INSERT is not a valid flag for AppendMenu and in fact maps to MF_ENABLED. In this case I believe you want to use MF_POPUP to insert the ‘View’ Sub menu.
This is how MSDN describes MF_POPUP: