Sign in to follow this  

Creating a submenu within a Pop-up menu

This topic is 4432 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
I've tried this but I ran into, unhandled exception errors.. plus it seems waaaay too hard.. I could be wrong.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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'

Share this post


Link to post
Share on other sites
You'll have to cast it like so:

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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this