-
Popup Menu
I'm working on a shell replacement.... Instead of a start menu, im wanting to make it so you right click on the desktop and it pops up a menu. I tried to do it from a resource, but I gave up on that. How do I do this? Same type of thing as a systray icon.
-
Code:
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(MNU_MAIN));
if(!hMenu || !IsMenu(hMenu) || !pOwner || !IsWindow(pOwner->m_hWnd)) return -1;
POINT thePoint;
GetCursorPos(&thePoint);
SetForegroundWindow(hWndParent);
int iID = TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_RIGHTALIGN | TPM_RETURNCMD, thePoint.x, thePoint.y, 0, pOwner->m_hWnd, NULL);
DestroyMenu(hMenu);
The highlighted line is important for tray icons, not sure about when randomly popping things up.
-
Oh yeah, it has to be a submenu off a menu, not on the root.
-
So how would this menu be layed out? (API or Diagram)
-
1 Attachment(s)
This is what it should look like.
GetSubMenu(hMenu, 0) gets the first submenu (the opened one) and uses that.
PS: You might need to save this and open it separately if it doesn't work because something's up with the server's MIME types.