Jump to content
  • Advertisement
Sign in to follow this  
Conqueran

Problem with Submenus

This topic is 4598 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'm creating a POP-UP menu in my window using the following code.. HMENU hmenu, ShadowMenu, ShadedMenu, LightingMenu; hmenu = CreatePopupMenu(); ShadowMenu = CreatePopupMenu(); ShadedMenu = CreatePopupMenu(); LightingMenu = CreatePopupMenu(); InsertMenu(ShadowMenu, 0, NULL, 2000, "Yes"); InsertMenu(ShadowMenu, 1, NULL, 2001, "No"); InsertMenu(ShadedMenu, 0, NULL, 3000, "Flat"); InsertMenu(ShadedMenu, 1, NULL, 3001, "Smooth"); InsertMenu(LightingMenu, 0, NULL, 4000, "Spotlight"); InsertMenu(LightingMenu, 1, NULL, 4001, "Point"); 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, MF_POPUP, (UINT_PTR)ShadowMenu, "Shadow" ); InsertMenu(hmenu, 4, NULL, 1004, "Blending Shadow" ); InsertMenu(hmenu, 5, NULL, 1005, "Quit" ); InsertMenu(hmenu, 6, NULL, 1006, "Wire Frame" ); InsertMenu(hmenu, 7, MF_POPUP, (UINT_PTR)ShadedMenu, "Shading" ); InsertMenu(hmenu, 8, MF_POPUP, (UINT_PTR)LightingMenu, "Lighting" ); I inserted all this in my WndProc at the beginning (probably a lame place to put it.. I then use case WM_CONTEXTMENU: TrackPopupMenu(hmenu, NULL, LOWORD(lParam), HIWORD(lParam), 0, hWnd, NULL); break; to load the menu... The submenu works fine after the first couple or so tries, but at one pt the submenu doesnt show at all! and it doesnt show until I restart the program.. Sometimes the submenu works for 10 times, sometimes it stops showing after only 2 times! How can I make it so the popup menu shows up ALL THE TIME? I wonder why it stops working? Does anyone know whats going on?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Conqueran
I inserted all this in my WndProc at the beginning (probably a lame place to put it..


Bingo.

Either put that code after your call to CreateWindow() or put it in your WM_CREATE handler. You'll need to make the hmenu variable global so that you can access it when you get a WM_CONTEXTMENU notification. You'll probably want the ShadowMenu, ShadedMenu, and LightingMenu variables to be global as well, so you can access them when you call DestroyMenu to clean them up.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!