Sign in to follow this  
Conqueran

Creating a submenu within a Pop-up menu

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this