我在VC的SDK编程中,
其资源中只建了一个菜单.
然后在主菜单中调用,预编译时没问题,运得或编译成.EXE文件时却报错!
代码与报错代码如下:
#include <windows.h>
#include "resource.h"
#define ID_EDITCHILD 12 bool initapplication(HINSTANCE)  ;
bool initinstance(HINSTANCE,int) ;
LRESULT APIENTRY winproc(HWND,UINT,WPARAM,LPARAM) ;HINSTANCE hinst ;
int APIENTRY WinMain(HINSTANCE hinstance,
 HINSTANCE hprevinstance,
 LPSTR     lpcmdline,
 int       nshowcmd)
{
MSG  msg ;
if (!initapplication(hinstance))
return false ;
if (!initinstance(hinstance,nshowcmd))
return false ;
hinst = hinstance ;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
};
return msg.wParam ;
};
bool initapplication(HINSTANCE hinstance) 
{
WNDCLASS wndclass ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH) ;
wndclass.hCursor = LoadCursor(hinstance,IDC_ARROW) ;
wndclass.hIcon = LoadIcon(hinstance,IDI_APPLICATION) ;
wndclass.hInstance = hinstance ;
wndclass.lpfnWndProc = (WNDPROC)winproc ;
wndclass.lpszClassName = "FILEDLGCLASS" ;
wndclass.lpszMenuName = MAKEINTRESOURCE(MENU) ;
wndclass.style = 0 ;
return (RegisterClass(&wndclass)) ;
};bool initinstance(HINSTANCE hinstance,int nshowcmd) 
{
HWND  hwnd ;
hwnd = CreateWindow("FILEDLGCLASS",
"这是文本程式示例",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
LoadMenu(hinstance,MAKEINTRESOURCE(MENU)),
hinstance,
NULL) ;
if (!hwnd)
return false ;
ShowWindow(hwnd,nshowcmd) ;
return true ;
};LRESULT APIENTRY winproc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) 
{
static HWND hwndedit ;
switch(message)
{
case WM_CREATE :
hwndedit = CreateWindow("EDIT",
NULL,
WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL|ES_LEFT|ES_MULTILINE
|ES_AUTOVSCROLL|ES_AUTOHSCROLL,
0,0,0,0,
hwnd,
(HMENU)ID_EDITCHILD,
hinst,
NULL) ;
ShowWindow(hwndedit,1) ;
break ;
case WM_COMMAND :
switch(LOWORD(wparam))
{
case IDM_EXIT :
SendMessage(hwnd,WM_DESTROY,0,0L) ;
break ;
};
break ;
case WM_DESTROY :
PostQuitMessage(0) ;
break;
default :
return (DefWindowProc(hwnd,message,wparam,lparam));
break;
};
return false ;
};出错代码为:
--------------------Configuration: 文件示例 - Win32 Debug--------------------
Compiling resources...
D:\文件示例\MENU.RC (57): error RC2164 : unexpected value in RCDATA
D:\文件示例\MENU.RC (59): error RC2135 : file not found: MENUITEM
D:\文件示例\MENU.RC (60): error RC2135 : file not found: MENUITEM
Error executing rc.exe.文件示例.exe - 3 error(s), 0 warning(s)附 :
菜单没问题,在资源中可以打开.