Hello all,
I have a quick question about context menus: can you use TrackPopupMenu on a "regular" menu?
Ex. To get a popup menu I use this in my resource:



#define IDM_CONTEXT 1002
IDM_CONTEXT MENU
{
POPUP "Example"
{
MENUITEM "Open",IDM_FILE_OPEN
}
}


I first have to load IDM_CONTEXT and then call GetSubMenu to get the popup "Example" to use with TrackPopupMenu. I can't simply use IDM_CONTEXT for this, and I think that would be more straightforward.

I'm pretty sure there's a way to do it, because when I use Norton Resource Editor, it allows you to "Test Menu As Popup" and it works fine.

Please Help
Thanks
--Chorus
Posted on 2002-11-24 14:14:52 by chorus
Chorus,
Do you want to use the contents of the 'window-menu' as a 'popup-menu'?
Window-Menu' == 'File | Edit | Help'


invoke GetMenu,hWnd ;\\ Get menu from window
invoke GetSubMenu,eax, 0;\\ Get First submenu from window. (0 == 'FILE')
mov hMenu,eax ;\\ Store handle to the menu
invoke TrackPopupMenu, hMenu, TPM_LEFTALIGN, X, Y, 0, hWnd, 0
Posted on 2002-11-24 14:48:08 by natas
Thanks for the reply natas

To answer your question... yes and no :)

No in that the menu I'm defining in the resource is not the "Window Menu"

Yes in that I want to define it in the same way in the resource file, but use it as a popup.

For instance, your example of "File|Edit|Help" I might not necessarily use as the window or class menu, but I would want to use it as a context menu (vertically, that is).

The "GetSubMenu" code you posted is essentially what I'm doing. But in this example, that would give me the File, or Edit, or Help popup, and not all 3.

Actually, a perfect example is the newest version of QEditor... you right click in the client area and get the whole menu.


Thanks
--Chorus
Posted on 2002-11-24 14:58:51 by chorus
Actually, if hutch-- reads this I wouldn't mind knowing how you did it in QEditor ??

Thanks
--Chorus
Posted on 2002-11-24 15:00:13 by chorus
Chorus, I hope that Hutch can give some pointers here. ( ;) )
But this is what I found out: When I dont use the getsubmenu call
I can display the whole 'window-menu' as a 'popup-menu'
invoke GetMenu,hWnd 	;\\ Get menu from window

mov hMenu,eax ;\\ Store handle to the menu
invoke TrackPopupMenu, hMenu, TPM_LEFTALIGN, X, Y, 0, hWnd, 0

Problem: It wont display the menu titles, like 'File | Edit | Help' etc.?
Well thats all I have gathered so far. Hutch! come out come out wherever
you are! ( :grin: )
Posted on 2002-11-24 17:09:39 by natas
I have a solution to this but the method is "not clean". Study the .rc file. :)



Remove invoke PostMessage, hWnd, WM_NULL, 0, 0 - not needed... :)
Posted on 2002-11-24 19:23:30 by stryker