2013-04-12 169 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

謝謝,它的工作 –

相關問題