Hi,can someone help? I am aware that many constants like ID_FILE_NEW is defined in "afxres.h". I tried to use ID_FILE_NEW constant in my menu, but it came out with the error shown below.
Code:
Deleting intermediate files and output files for project 'xWrite - Win32 Debug'.
--------------------Configuration: xWrite - Win32 Debug--------------------
Compiling resources...
Compiling...
mainFrame.cpp
c:\documents and settings\edmund\my documents\my ebooks\my expt files\windows workspace\xwrite\mainframe.cpp(129) : error C2065: 'ID_FILE_NEW' : undeclared identifier
c:\documents and settings\edmund\my documents\my ebooks\my expt files\windows workspace\xwrite\mainframe.cpp(129) : error C2051: case expression not constant
skeleton.cpp
winMain.cpp
Error executing cl.exe.
xWrite.exe - 2 error(s), 0 warning(s)
I am using VC++. Here is my resource.h and resource.rc:
Code:
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAIN MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
MENUITEM "E&xit", ID_FILE_EXIT
END
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDR_MAIN "mainFrame class"
IDS_MAINTITLE "Main Frame"
ID_EDIT "edit control identifier"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Code:
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by resource.rc
//
#define IDR_MAIN 101
#define IDS_MAINTITLE 102
#define ID_EDIT 103
#define MAX_RESOURCESTRING 255
#define ID_FILE_EXIT 40001
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40002
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Using the ID_FILE_NEW in this function call in a wndProc where WM_COMMAND is received:
Code:
void mainFrame::mainWindow_onCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{case ID_FILE_EXIT: DestroyWindow(hwnd);
break;
case ID_FILE_NEW: Edit_SetText(hEditCntl,NULL);
break;
default: FORWARD_WM_COMMAND(hwnd,id,hwndCtl,codeNotify,DefWindowProc);
}
}