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

Dark Star

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

Recommended Posts

Dark Star    100
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);
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;

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; 
  TrackPopupMenuEx(popMenu,TPM_HORIZONTAL | TPM_VERTICAL |   TPM_LEFTALIGN | TPM_RETURNCMD,pt.x,pt.y,global_hwd,NULL);

this works 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" 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]

Share this post

Link to post
Share on other sites
Colin Jeanne    1114
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

Share this post

Link to post
Share on other sites