Creating a submenu within a Pop-up menu
I'd like to create a submenu within a popup menu using c++. I have this so far
HMENU hmenu; //set up pop-up menu
hmenu = CreatePopupMenu();
InsertMenu(hmenu, 0, NULL, 1000, "Default View Point");
InsertMenu(hmenu, 1, NULL, 1001, "Fog Options" );
InsertMenu(hmenu, 2, NULL, 1002, "Texture Mapping" );
InsertMenu(hmenu, 3, NULL, 1003, "Shadow" );
InsertMenu(hmenu, 4, NULL, 1004, "Blending Shadow" );
InsertMenu(hmenu, 5, NULL, 1005, "Quit" );
InsertMenu(hmenu, 6, NULL, 1006, "Wire Frame" );
InsertMenu(hmenu, 7, NULL, 1007, "Shading" );
InsertMenu(hmenu, 8, NULL, 1008, "Lighting" );
This creates a menu with 9 different items... However I want the "Fog Options" choice to be a menu itself! When its selected I'd like a new menu to show to the right.. Just like windows does with menus often.. How do I do this using InsertMenu?
Have a look at using InsertMenuItem instead of InsertMenu. This says that InsertMenuItem should be used now instead of AppendMenu and InsertMenu.
I've tried this but I ran into, unhandled exception errors.. plus it seems waaaay too hard.. I could be wrong.
Create the submenu (with another CreatePopupMenu call). Then call InsertMenu with MF_POPUP as the flags parameter, and your submenu's handle in the id parameter.
I tried this but I get the following error.
HMENU hmenu, ShadowMenu; //set up pop-up menu
hmenu = CreatePopupMenu();
ShadowMenu= CreatePopupMenu();
InsertMenu(hmenu, 0, NULL, 1000, "Default View Point");
InsertMenu(hmenu, 1, MF_POPUP, ShadowMenu, "Fog Options");
InsertMenu(hmenu, 2, NULL, 1002, "Texture Mapping" );
............
..........
..........
...........
'InsertMenuA' : cannot convert parameter 4 from 'struct HMENU__ *' to 'unsigned int'
HMENU hmenu, ShadowMenu; //set up pop-up menu
hmenu = CreatePopupMenu();
ShadowMenu= CreatePopupMenu();
InsertMenu(hmenu, 0, NULL, 1000, "Default View Point");
InsertMenu(hmenu, 1, MF_POPUP, ShadowMenu, "Fog Options");
InsertMenu(hmenu, 2, NULL, 1002, "Texture Mapping" );
............
..........
..........
...........
'InsertMenuA' : cannot convert parameter 4 from 'struct HMENU__ *' to 'unsigned int'
You'll have to cast it like so:
(UINT_PTR is typedef'd as WPARAM, which is typedefed as unsigned int)
edit - case = cast
[Edited by - Dave Hunt on November 29, 2005 11:38:23 AM]
InsertMenu(hmenu, 1, MF_POPUP, (UINT_PTR)ShadowMenu, "Fog Options");
(UINT_PTR is typedef'd as WPARAM, which is typedefed as unsigned int)
edit - case = cast
[Edited by - Dave Hunt on November 29, 2005 11:38:23 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement