Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Coaster Kev

TrackPopupMenu problem...

This topic is 5686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For my notify icon (system tray icon), i am adding a popup menu for it when you right click on the icon. Here is the code:
        
case WM_RBUTTONDOWN:
{
        POINT cursor;
        GetCursorPos(&cursor);
	SetForegroundWindow(hwnd);

	TrackPopupMenu(LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_TASKBAR)), TPM_RIGHTBUTTON | TPM_RIGHTALIGN, cursor.x, cursor.y, 0, hwnd, 0);

	PostMessage(hwnd, WM_NULL, 0, 0);
						
} break;
      
Problem is that when i execute it, all I get is a vertical bar, no menu. I thought I read here before a solution for it, but dang the search doesn't work. Thanks for any input. [edited by - Coaster Kev on January 22, 2003 9:52:49 PM]

Share this post


Link to post
Share on other sites
Advertisement
Try this:

TrackPopupMenu(GetSubMenu(LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_TASKBAR)),0), TPM_RIGHTBUTTON | TPM_RIGHTALIGN, cursor.x, cursor.y, 0, hwnd, 0);

[edited by - SilentReaper on January 22, 2003 10:54:44 PM]

Share this post


Link to post
Share on other sites
How'd you actually create your menu? I make one top-level popup menu with a generic name that doesn't get displayed (normally I call it POPUP-MENU). Under that I have several menuitems. Kind of like what you'd expect under a File or Edit menu, etc... Anyways, this code works for me:


  
// Inside main window message proc

static HMENU hTrayMenu;
...
switch(msg)
{
case WM_CREATE:
...
CreateTrayIcon();
hTrayMenu = GetSubMenu(LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_TRAY)),0);
...
case WM_TRAY_NOTIFICATION:
if (LOWORD(lParam) == WM_RBUTTONUP)
{
SetForegroundWindow(hWnd);
GetCursorPos(&pt);
... // Put checkmarks on menuitems using CheckMenuItem

TrackPopupMenu(hTrayMenu,TPM_RIGHTBUTTON,pt.x,pt.y,0,hWnd,NULL);
...


[edited by - SilentReaper on January 22, 2003 11:23:32 PM]

Share this post


Link to post
Share on other sites
Just out of curiosity -- why the PostMessage()?

quote:
Original post by Coaster Kev
Made it with the resource editor in VC.

Well, I figured that . Just was trying to get if you made them under one popup menu or some other way. If you open your .rc file in a text editor and find the definition for your menu, is it similar to:


  IDR_TRAY MENU DISCARDABLE 
BEGIN
POPUP "POPUP-MENU"
BEGIN
MENUITEM "Disable Windows Key", ID_POPUPMENU_DISABLEWINDOWSKEY

MENUITEM "Run on Windows Startup", ID_POPUPMENU_RUNONWINDOWSSTARTUP

MENUITEM "About", ID_POPUPMENU_ABOUT
MENUITEM SEPARATOR
MENUITEM "Exit", ID_POPUPMENU_EXIT
END
END

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!