Is it possible to Create System Tray menu from a resource menu in VC++

Started by
0 comments, last by Dark Star 19 years, 10 months ago
Hi all, I created a simple menu with VC++ as a resource and created an icon which happyly appears in the system tray in windows XP. I have attached the menu to the system tray icon like so:


// Get menu from resources

HMENU popMenu = LoadMenu(hInstance,(LPCSTR)IDR_MENU1);
	 
NOTIFYICONDATA nid;
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = global_hwd;
nid.hIcon= LoadIcon(hInstance, (LPCTSTR)IDI_SMALL);
nid.uCallbackMessage= WM_APP;
strcpy(nid.szTip,"Hidden Window");
nid.uID = 1;
nid.uFlags = NIF_TIP | NIF_ICON | NIF_MESSAGE;

Shell_NotifyIcon(NIM_ADD,&nid);
and then later on I wanted to show the menu when the icon in the system tray is clicked like so:
   
if (lParam==WM_LBUTTONDOWN )
{
  POINT pt; 
  GetCursorPos(&pt);
  
  TrackPopupMenuEx(popMenu,TPM_HORIZONTAL | TPM_VERTICAL |   TPM_LEFTALIGN | TPM_RETURNCMD,pt.x,pt.y,global_hwd,NULL);
}

this works fine....it shows the icon in system tray and when clicked with left mouse button the menu comes up but without the menu text. Infact the menu appears "thin"..like only a few pixels wide. The height is the right but not the width. If anymenu option has a pop up menu, then that menu shows properly.. what am I doing wrong? DarkStar UK [ confused ] ------------------------------- Loves cross-posting because it works [edited by - Dark Star on May 27, 2004 5:00:32 PM]
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Advertisement
Have you tried using GetSubMenu() on popMenu and passing that to TrackPopupMenuEx()?

Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

This topic is closed to new replies.

Advertisement