How do you get a submenu to come out from a menu item?

This is a discussion on How do you get a submenu to come out from a menu item? within the Windows Programming forums, part of the Platform Specific Boards category; I can't seem to find any tutorials on how to do this, but I want to add a submenu onto ...

  1. #1
    Registered User Swarvy's Avatar
    Join Date
    Apr 2008
    Location
    United Kingdom
    Posts
    195

    How do you get a submenu to come out from a menu item?

    I can't seem to find any tutorials on how to do this, but I want to add a submenu onto menu items, so that when the mouse hovers over it, another menu comes out from that. How would I do it?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I would search MSDN for submenus. They also have a mixed C#/C++ walkthrough which may or may not be helpful.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    I use AppendMenu() to set up my menus, and then you just create another menu and set it as a child of another menu.
    Code:
    //Handles for menu
                MainMenu = CreateMenu();
                SubMenu = CreatePopupMenu();
    
                //File menu
                AppendMenu(MainMenu,MF_POPUP|MF_STRING,(UINT)SubMenu,"&File");
                AppendMenu(SubMenu,MF_POPUP,FILE_RESET,"Reset");
                AppendMenu(SubMenu,MF_SEPARATOR,NULL,NULL);
                AppendMenu(SubMenu,MF_POPUP,FILE_EXIT,"Exit");
    
                SubMenu = CreatePopupMenu();
                HMENU SubMenuTwo = CreatePopupMenu(); //create submenu
                AppendMenu(MainMenu,MF_POPUP,(UINT)SubMenu,"&View");
                AppendMenu(SubMenu,MF_POPUP|MF_STRING,EXTENDED,"Extended View");
                AppendMenu(SubMenu,MF_POPUP,(UINT)SubMenuTwo,"Reference");
                   AppendMenu(SubMenuTwo,MF_POPUP,REF_OPEN,"Open References"); //this is the submenu and the 'parent' is "Reference"
    
                SubMenu = CreatePopupMenu();
                AppendMenu(MainMenu,MF_POPUP,(UINT)SubMenu,"&Options");
                AppendMenu(SubMenu,MF_POPUP,OPTIONS_CH,"Options Choices");
    
                SubMenu = CreatePopupMenu();
                AppendMenu(MainMenu,MF_POPUP,(UINT)SubMenu,"&Help");
                AppendMenu(SubMenu,MF_POPUP,ABOUT_ABOUT,"About");
                AppendMenu(SubMenu,MF_POPUP,INFO,"Info");
    
                //Make menu appear on screen
                SetMenu(hwnd,MainMenu);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 11:52 AM
  2. Retail Outlet Managment System - the 4th
    By Presidentofusa in forum C Programming
    Replies: 3
    Last Post: 11-10-2007, 09:44 PM
  3. Best "Menu" method?
    By SSJMetroid in forum Game Programming
    Replies: 11
    Last Post: 12-07-2005, 11:05 PM
  4. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21