Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problem with Submenus

Started by Conqueran Dec 18, 2005 at 8:54 PM 1 replies 750+ views
Original Post
Conqueran
Conqueran
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?
Dave Hunt
Dave Hunt
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.
Conqueran
Conqueran
Thanks. Everything works smoothly now :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.