Results 1 to 5 of 5

Thread: Popup Menu

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73

    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.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Oh yeah, it has to be a submenu off a menu, not on the root.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73
    So how would this menu be layed out? (API or Diagram)

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width