2013-04-12 173 views
2

我在向C++窗口菜单中的菜单项添加子菜单项时遇到了问题。我正在为我的游戏添加一个数字(确切地说是20)。将子菜单项添加到菜单项

这里是我对保存插槽代码:

HMENU win32MENU = CreateMenu();//Menu bar 

    HMENU win32SETTINGS = CreateMenu();//Settings option 
     HMENU win32SAVESLOTS = CreateMenu();//Save Slots 

    AppendMenu(win32MENU,MF_POPUP,(UINT_PTR)win32SETTINGS,"Settings"); 

    //Settings 
    AppendMenu(win32SETTINGS,MF_STRING,(UINT_PTR)win32SAVESLOTS,"Save      Ctrl+S"); 

     //Save Slots 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Default ~"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 1"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 2"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 3"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 4"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 5"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 6"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 7"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 8"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 9"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 10"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 11"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 12"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 13"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 14"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 15"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 16"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 17"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 18"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 19"); 
     AppendMenu(win32SAVESLOTS,MF_STRING,NULL,"Save Slot 20"); 

在此先感谢。

+0

你能描述这种方式不起作用吗?此外,如果您可以摆脱所有* *的*代码工作的代码,这将有助于专注于哪些不会。 –

+0

当我将鼠标移到“保存”选项上时,它不能显示另一个菜单。我会展示一张图片来展示我的意思,但是因为我是新手,所以不会让我这样做。我可以确实这样做。等一下。 –

回答

2

变化:

AppendMenu(win32SETTINGS,MF_STRING,(UINT_PTR)win32SAVESLOTS,"Save Ctrl+S");

AppendMenu(win32SETTINGS,MF_STRING | MF_POPUP,(UINT_PTR)win32SAVESLOTS,"Save Ctrl+S");

另外,更改

HMENU win32SAVESLOTS = CreateMenu();//Save Slots

HMENU win32SAVESLOTS = CreatePopupMenu();//Save Slots

+0

谢谢,它的工作 –

相关问题