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:
my resource file: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)
menu.h: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 } }
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 ///////////////////////////////////////////////////////



LinkBack URL
About LinkBacks


