some questions on menu~

This is a discussion on some questions on menu~ within the Windows Programming forums, part of the Platform Specific Boards category; hi all~ i've created a simple window and now have a few questions about menu: 1. my book told me ...

  1. #1
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563

    some questions on menu~

    hi all~

    i've created a simple window and now have a few questions about menu:

    1. my book told me to build a menu we need create certain menu class and corresponding header files first, but how to make it manually ?
    2. how to config the menu(or the whole window) appears as win2k or winxp style ?(just like what dev-c++ do)

    tks.
    Never end on learning~

  2. #2
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    You should try searching for Ownerdraw menu
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,264
    Here is the code I'm using in my current project to create a menu:
    Code:
    	/* Create the menu */
    	{
    		HMENU		hFileMenu, hWindowMenu, hViewMenu;
    
    		/* Create the "File" menu, and its selections */
    		hFileMenu = CreateMenu();
    		AppendMenu(hFileMenu,0,IDMENU_FILE_NEW,_T("New"));
    		AppendMenu(hFileMenu,0,IDMENU_FILE_CLOSE,_T("Close"));
    		AppendMenu(hFileMenu,0,IDMENU_FILE_CLOSEALL,_T("Close All"));
    		AppendMenu(hFileMenu,MF_SEPARATOR,0,0);
    		AppendMenu(hFileMenu,0,IDMENU_FILE_CONNECT,_T("Connect"));
    		AppendMenu(hFileMenu,MF_SEPARATOR,0,0);
    		AppendMenu(hFileMenu,0,IDMENU_FILE_EXIT,_T("Exit"));
    
    		/* Create the "View" menu */
    		hViewMenu = CreateMenu();
    		AppendMenu(hViewMenu,0,IDMENU_VIEW_SETTINGS,_T("Settings"));
    
    		/* Create the "Window" menu */
    		hWindowMenu = CreateMenu();
    
    		/* Create the Frame menu, and add all the sub menus to it */
    		g_hMenuFrame = CreateMenu();
    		AppendMenu(g_hMenuFrame,MF_POPUP,(UINT_PTR)hFileMenu,_T("File"));
    		AppendMenu(g_hMenuFrame,MF_POPUP,(UINT_PTR)hViewMenu,_T("View"));
    		AppendMenu(g_hMenuFrame,MF_POPUP,(UINT_PTR)hWindowMenu,_T("Window"));
    	}
    All the IDMENU_* identifiers need to be defined somewhere in your project. Once you have the menu created (g_hMenuFrame in my example code), you then pass that menu handle to CreateWindow().

  4. #4
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    Quote Originally Posted by bithub
    Here is the code I'm using in my current project to create a menu:
    Code:
    	/* Create the menu */
    	{
    		HMENU		hFileMenu, hWindowMenu, hViewMenu;
    
    		/* Create the "File" menu, and its selections */
    		hFileMenu = CreateMenu();
    		AppendMenu(hFileMenu,0,IDMENU_FILE_NEW,_T("New"));
    		AppendMenu(hFileMenu,0,IDMENU_FILE_CLOSE,_T("Close"));
    		AppendMenu(hFileMenu,0,IDMENU_FILE_CLOSEALL,_T("Close All"));
    		AppendMenu(hFileMenu,MF_SEPARATOR,0,0);
    		AppendMenu(hFileMenu,0,IDMENU_FILE_CONNECT,_T("Connect"));
    		AppendMenu(hFileMenu,MF_SEPARATOR,0,0);
    		AppendMenu(hFileMenu,0,IDMENU_FILE_EXIT,_T("Exit"));
    
    		/* Create the "View" menu */
    		hViewMenu = CreateMenu();
    		AppendMenu(hViewMenu,0,IDMENU_VIEW_SETTINGS,_T("Settings"));
    
    		/* Create the "Window" menu */
    		hWindowMenu = CreateMenu();
    
    		/* Create the Frame menu, and add all the sub menus to it */
    		g_hMenuFrame = CreateMenu();
    		AppendMenu(g_hMenuFrame,MF_POPUP,(UINT_PTR)hFileMenu,_T("File"));
    		AppendMenu(g_hMenuFrame,MF_POPUP,(UINT_PTR)hViewMenu,_T("View"));
    		AppendMenu(g_hMenuFrame,MF_POPUP,(UINT_PTR)hWindowMenu,_T("Window"));
    	}
    All the IDMENU_* identifiers need to be defined somewhere in your project. Once you have the menu created (g_hMenuFrame in my example code), you then pass that menu handle to CreateWindow().
    tks man ! i love CreateMenu lol
    Never end on learning~

  5. #5
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    one more thing, is there any efficiency difference btween CreateMenu and .rc resources ? i think program size may be smaller by CreateMenu way but less efficiency when running, anyway i dont proof it.
    Never end on learning~

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,264
    If there is a difference, it's too small to worry about.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 09:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 06:36 AM
  3. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 08:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 08:22 AM

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