Creating Menus ... Correct steps

This is a discussion on Creating Menus ... Correct steps within the Windows Programming forums, part of the Platform Specific Boards category; Have made an attempt with the following steps, no menu shows yet 1. Created a resource file (in Using VS ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    Creating Menus ... Correct steps

    Have made an attempt with the following steps, no menu shows yet

    1. Created a resource file (in Using VS 2005)

    - Went to Project Properties, Add > New > Resource File and named it Menu.rct (note, in VS2005 is rct not rc)
    - Added the menu (no code was required in VS 2005)
    unlike earlier version (i.e)
    Code:
       #include "resource.h"
       IDM_MENU MENU 
       BEGIN
          POPUP "&File"
          {
              MENUITEM "E&xit", ID_FILE_EXIT
          }
    
          POPUP "&Edit"
          {
              MENUITEM "Copy",ID_EDIT_COPY
          }
          POPUP "&Help"
          {
              MENUITEM "&About", ID_HELP_ABOUT
          }
       END
    ...and gave ID of IDR_MAINMENU

    2. Edited CreateWindowEx()

    Code:
    	wcx.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
    3. Added a resource.h file

    Code:
    #define IDR_MAINMENU		102
    #define ID_FILE_EXIT		40001
    #define ID_FILE_OPEN		40002
    #define ID_FILE_SAVEAS		40003
    #define ID_FILE_NEW			40004
    
    // Next default values for new objects
    // 
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE        103
    #define _APS_NEXT_COMMAND_VALUE         40005
    #define _APS_NEXT_CONTROL_VALUE         1000
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif
    4. WM_COMMAND

    Code:
    			case ID_FILE_EXIT:
    				{
    					PostMessage(hwnd, WM_CLOSE, 0, 0);
    					break;
    				}
    
    			case ID_FILE_NEW:
    				{
    					//ClearEditControls(hwnd, IDC_MAIN_EDIT, "");
    					break;
    				}
    			case ID_FILE_OPEN:
    				{
    					// Load data from file to edit controls
    					DoFileOpen(hwnd);
    					SetValues(hwnd, &indata);
    					break;
    				}
    			case ID_FILE_SAVEAS:
    				{
    					// Save data on edit controls to file
    					DoFileSave(hwnd);
    					break;
    				}
    Is there anything am missing somewhere?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,033
    I'm dubious. Are you compiling with Express? You must make sure the resources is compiled into your executable, and resource files are named .rc. Although Express has no resource editor.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Elysia View Post
    I'm dubious. Are you compiling with Express?
    No, standard...

    You must make sure the resources is compiled into your executable
    How exactly do i do this.. If the resource file is added to a project doesn't do the rest?

    , and resource files are named .rc. Although Express has no resource editor.
    Well, i didn't name the extension, it was named by default... Not sure what would happen if i rename it to rc.


    Something else, i'm only adding a menu now after i've drawn rectangles on my window... Normally the position of the menu is just below the blue bar and above the rectangle area... Could the rectangle(s) i've drawn be in the way of the menu? Or does the menu item automatically get inserted above the existing objects in the window...

  4. #4
    Registered User
    Join Date
    May 2008
    Posts
    2
    In the resource file, the ID of you menu was IDM_MENU.

    Did you change that to IDR_MAINMENU?

    Try adding DISCARDABLE to the menu resource so it doesn't waste memory.

    Code:
    IDR_MAINMENU MENU DISCARDABLE

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,033
    .rct is a Resource Template File. I'm thinking you're using the wrong resource.
    Instead add a new item and select resource (.rc).
    Then use the resource editor to add your menu and name it appropriately.
    Visual Studio will automatically compile the resource into the executable.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Elysia View Post
    .rct is a Resource Template File. I'm thinking you're using the wrong resource.
    Instead add a new item and select resource (.rc).
    Then use the resource editor to add your menu and name it appropriately.
    Visual Studio will automatically compile the resource into the executable.
    This is where my mistake was, thanx... Working now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating Child with parent of Child
    By SilkySmooth in forum Windows Programming
    Replies: 3
    Last Post: 06-28-2003, 01:15 PM
  2. Creating a student grade book-how?
    By Hopelessly confused in forum C Programming
    Replies: 5
    Last Post: 10-03-2002, 09:43 PM
  3. Replies: 3
    Last Post: 07-24-2002, 09:46 AM
  4. Creating my own button
    By minesweeper in forum Windows Programming
    Replies: 1
    Last Post: 07-19-2002, 02:38 PM
  5. Inheritance related question. Is this correct?
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 07-19-2002, 05:30 AM

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