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;
TrackPopupMenu problem...
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:
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]
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]
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]
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:
[edited by - SilentReaper on January 22, 2003 11:23:32 PM]
// 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]
Just out of curiosity -- why the PostMessage()?
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:
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement