Archived

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

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

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);

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 on other sites
Try this:

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

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 procstatic 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 on other sites
Made it with the resource editor in VC.

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    ENDEND

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 30
• 9
• 16
• 22