johnny_no1_boy

Hello.I have in my application a popup menu that is available in system tray.I have different items.My question is how I can add subitems to that menu.I use VC++ and Win32.Thanks...


Re: Visual C++ General How to create a menu with subitems?

Pintu Shukla

What's The problem you are getting . Show your Code here so anyone can help you and same time have a look in MSDN for

CreateMenu()
CreatePopupMenu()
AppendMenu()

Thanx





Re: Visual C++ General How to create a menu with subitems?

johnny_no1_boy

HMENU Menu_TrayIcon = CreatePopupMenu();
AppendMenu(Menu_TrayIcon,MF_STRING,ID_SHOWWIN,"Open");
AppendMenu(Menu_TrayIcon,MF_SEPARATOR,ID_MENUSEPARATOR,"Separator");
if(IsIconic(hWnd)==1)
AppendMenu(Menu_TrayIcon,MF_STRING,ID_MINMAXBUTTON,"Maximize");
else
AppendMenu(Menu_TrayIcon,MF_STRING,ID_MINMAXBUTTON,"Minimize");
AppendMenu(Menu_TrayIcon,MF_STRING,ID_FULLSCREEN,"Fullscreen");
AppendMenu(Menu_TrayIcon,MF_STRING,ID_OPTIONS,"Options");
AppendMenu(Menu_TrayIcon,MF_STRING,ID_ABOUT,"About...");
AppendMenu(Menu_TrayIcon,MF_SEPARATOR,ID_MENUSEPARATOR,"Separator");
AppendMenu(Menu_TrayIcon,MF_STRING,ID_CLOSE,"Close");
SetMenuDefaultItem(Menu_TrayIcon, ID_SHOWWIN, false);
GetCursorPos(&pt);
SetForegroundWindow(hWnd);
TrackPopupMenu(Menu_TrayIcon,TPM_RIGHTALIGN,pt.x,pt.y,0,hWnd,NULL);


I don't have a real problem.I don't now how to make that when the user is over Option to apear other items.
(EX: When u go over "All Programs"(in Start Menu)...then it appear new items in the right->Accessories, StartUp,etc....




Re: Visual C++ General How to create a menu with subitems?

Ramkrishna Pawar

You mean you want to add a child menu to one of the main menu items






Re: Visual C++ General How to create a menu with subitems?

johnny_no1_boy

yes



Re: Visual C++ General How to create a menu with subitems?

johnny_no1_boy

but how I can add a child menu




Re: Visual C++ General How to create a menu with subitems?

Bite Qiu - MSFT

johnny_no1_boy wrote:
but how I can add a child menu

Use MF_POPUP to add submenu, see:

Code Snippet

HMENU Menu_TrayIcon = CreatePopupMenu();

HMENU hSubMenu = CreatePopupMenu();

::AppendMenu(Menu_TrayIcon,MF_POPUP,(UINT)hSubMenu,_T("submenu"));
::AppendMenu(hSubMenu,MF_STRING,10000,_T("sub menu item 1"));

// append sub menu's items here
AppendMenu(Menu_TrayIcon,MF_STRING,ID_SHOWWIN,"Open");
AppendMenu(Menu_TrayIcon,MF_SEPARATOR,ID_MENUSEPARATOR,"Separator");
if(IsIconic(hWnd)==1)
AppendMenu(Menu_TrayIcon,MF_STRING,ID_MINMAXBUTTON,"Maximize");
else
AppendMenu(Menu_TrayIcon,MF_STRING,ID_MINMAXBUTTON,"Minimize");
AppendMenu(Menu_TrayIcon,MF_STRING,ID_FULLSCREEN,"Fullscreen");
AppendMenu(Menu_TrayIcon,MF_STRING,ID_OPTIONS,"Options");
AppendMenu(Menu_TrayIcon,MF_STRING,ID_ABOUT,"About...");
AppendMenu(Menu_TrayIcon,MF_SEPARATOR,ID_MENUSEPARATOR,"Separator");
AppendMenu(Menu_TrayIcon,MF_STRING,ID_CLOSE,"Close");
SetMenuDefaultItem(Menu_TrayIcon, ID_SHOWWIN, false);
GetCursorPos(&pt);
SetForegroundWindow(hWnd);
TrackPopupMenu(Menu_TrayIcon,TPM_RIGHTALIGN,pt.x,pt.y,0,hWnd,NULL);

hope it helps

rico