Re: Popup (or Context) Menu
Quote:
Originally Posted by Comadreja
The problem is that i'm not getting the captions of the menu shown. Instead, the menu appears as if my captions where one blank space each. Still i get all the WM_COMMAND message well on each caption, and even popup submenus appear correctly (Opcion4). Any idea in what I might be doing wrong?
When loading a popup menu from a resource, you need to define a top-level, 'dummy' popup menu under which you create the items you want to display. The top level item will never actually show when displaying a popup menu.
Re: Popup (or Context) Menu
Thanks a lot!!!! That worked!
I made the 'dummy' popup menu, then obtained a handle to the submenu and it loaded OK.
I insert the code working in case it helps someone else
Code:
/**************** RESOURCE.H ********************/
IDR_MENU MENU DISCARDABLE
BEGIN
POPUP "Menu Popup"
BEGIN
MENUITEM "Opcion1", IDMP_1
MENUITEM "Opcion2", IDMP_2
MENUITEM "Opcion3", IDMP_2
END
END
/************* MAINAPP.cpp *******************/
[...]
// INIT INSTANCE
m_hMenuPopup = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU));
[...]
// MESSAGE LOOP
case WM_RBUTTONDOWN:
TrackPopupMenuEx(GetSubMenu(m_hMenuPopup,0), TPM_LEFTALIGN,
m_cursor.x, m_cursor.y, hWnd, NULL);
[...]
What I still don't understand is why the captions didn't appear without the 'dummy menu'. It might be because it is a popup menu?? And if so, why appending the captions directly in the code worked well?
Nevermind, if it works it works! :rolleyes:
Now I'm getting into a new question: is there any function to easily change the captions of the menu without affecting its IDs? I'm thinking of multi-language GUI, and a way to load all the new captions from a file when changing the language. I'm investigating the InsertMenuItem function but it don't find a way to just replace the caption without changing anything else. Any idea on this?