Need help with making menus

This is a discussion on Need help with making menus within the Windows Programming forums, part of the Platform Specific Boards category; i have the menu built and added into my windows and now im trying to make it do certain things ...

  1. #1
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114

    Need help with making menus

    i have the menu built and added into my windows and now im trying to make it do certain things when people click on the items. here are my errors:

    Code:
    --------------------Configuration: icons - Win32 Debug--------------------
    Compiling...
    source.cpp
    C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Windows 
    Programming\Chapter Three\icons\source.cpp(77) : error C2065: '_MENU_EXIT' : undeclared identifier
    
    C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Windows Programming\Chapter Three\icons\source.cpp(77) :
     error C2051: case expression 
    not constant
    
    C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Windows Programming\Chapter Three\icons\source.cpp(81)
     : warning C4060: switch statement contains no 'case' or 'default' labels
    Error executing cl.exe.
    
    icons.exe - 2 error(s), 1 warning(s)
    my resource file:


    Code:
    #include "MENU.H"
    
    _ICON ICON t3dx.ico
    _CURSOR CURSOR blue.cur
    _MUSIC WAVE loop.wav 
    
    _MENU MENU DISCARDABLE
    {
    POPUP "File"
    	{
    	MENUITEM "&New", _MENU_NEW
    	MENUITEM "&Open", _MENU_OPEN
    	MENUITEM "&Close", _MENU_CLOSE
    	MENUITEM "&Save",_MENU_SAVE
    	MENUITEM "E&xit",_MENU_EXIT
    	}
    POPUP "Help"
    	{
    	MENUITEM "&Help",_MENU_HELP
    	MENUITEM "&About",_MENU_ABOUT
    	}
    }
    menu.h:

    Code:
    /*====================================================================
    *
    *		"Tricks of the windows game programming gurus"
    *
    *		Nathan Krygier			6/17/05
    *		Chapter 3				Example Two "MENU.H"
    *
    *///==================================================================
    
    //File Menu
    #ifndef _MENU_NEW
    #define _MENU_NEW		1000
    #endif
    
    #ifndef _MENU_OPEN
    #define _MENU_OPEN		1001
    #endif
    
    #ifndef _MENU_CLOSE
    #define _MENU_CLOSE		1002
    #endif
    
    #ifndef _MENU_SAVE
    #define _MENU_SAVE		1003
    #endif
    
    #ifndef _MENU_EXIT
    #define _MENU_EXIT		1004
    #endif
    
    // Help menu
    #ifndef _MENU_HELP
    #define _MENU_HELP		2000
    #endif
    
    #ifndef _MENU_ABOUT
    #define _MENU_ABOUT		2001
    #endif

    the winproc function:


    Code:
    // WINPROC ///////////////////////////////////////////////////////////
    LRESULT CALLBACK WindowProc(HWND hwnd, 
    						    UINT msg, 
                                WPARAM wparam, 
                                LPARAM lparam)
    {
    
    PAINTSTRUCT		ps;		
    HDC					hdc;
    	
    // check for message type
    switch(msg)
    	{
    	// WM_CREATE //////////////////////////////////////////////////////
    	case WM_CREATE: 
            {
    		// do initialization stuff here
           
            PlaySound("_MUSIC", hinstance_app, SND_RESOURCE | SND_ASYNC | SND_LOOP);
    
    		return(0);
    		} break;
    	// WM_COMMAND ///////////////////////////////////////////////////
    	case WM_COMMAND:
    		{
    		switch (LOWORD(wparam))
    		{
    		case _MENU_EXIT:
    		{
    			PostQuitMessage(0);
    		}break;
    		}
    		}break;
    	// WM_PAINT /////////////////////////////////////////////////////
    	case WM_PAINT: 
    		{
    		hdc = BeginPaint(hwnd,&ps);
    		
    		// you would do all your painting here
            EndPaint(hwnd,&ps);
    
    		return(0);
       		} break;
    	// WM_DESTORY ////////////////////////////////////////////////////
    	case WM_DESTROY: 
    		{
    
            PlaySound(NULL, hinstance_app, SND_PURGE);
    
    		// kill the application, this sends a WM_QUIT message 
    		PostQuitMessage(0);
    
    		return(0);
    		} break;
    
    	default:break;
    
        }
    
    // process any messages that we didn't take care of 
    return (DefWindowProc(hwnd, msg, wparam, lparam));
    
    } // ENDWINPROC ///////////////////////////////////////////////////////
    Last edited by Frantic-; 06-18-2005 at 08:08 AM.

  2. #2
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114
    anyone?

  3. #3
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Well, for one.....
    Code:
    #include "MENU.H"
    I don't know about the "menu" part, but the ".h" should never be caitalized.
    And did you
    Code:
    #include "menu.h"
    in both your resource AND your source file? If you didn't, that woud explain your first error. If it says it's undeclared, it's not declared.
    Code:
    void function(void)
     {
      function();
     }

  4. #4
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114
    ahh thanks. I thought that because menu.h was declared in my res file, that I didnt need it in the cpp file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making sprites
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 02-20-2010, 06:00 AM
  2. Making great graphics
    By MadCow257 in forum Game Programming
    Replies: 1
    Last Post: 02-20-2006, 10:59 PM
  3. Making text menus
    By kzar in forum C Programming
    Replies: 6
    Last Post: 03-31-2005, 07:50 AM
  4. Menu's
    By Benzakhar in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2004, 09:13 PM
  5. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 07:37 AM

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