关于Windows程序设计的简单问题
#include <windows.h>
#include"resource.h"
#define ID_TIMER 1
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
.....
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int idColor[5]={WHITE_BRUSH,LTGRAY_BRUSH,GRRAY_BRUSH,DKGRAY_BRUSH,BLACK_BRUSH};
static int iSelection=IDM_BKGND_WHITE;
HMENU hMenu;
switch (message)
{
case WM_COMMAND:
hMenu=GetMenu(hwnd);
switch(LOWORD(wParam))
{
case IDM_FILE_NEW:
case IDM_FILE_OPEN:
case IDM_FILE_SAVE:
case IDM_FILE_SAVE_AS:
MessageBeep(0);
return 0;
case IDM_APP_EXIT:
SendMessage(hwnd,WM_CLOSE,0,0);
return 0;
case IDM_EDIT_UNDO:
case IDM_EDIT_CUT:
case IDM_EDIT_COPY:
case IDM_EDIT_PASTE:
case IDM_EDIT_CLEAR:
MessageBeep(0);
return 0;
case IDM_BKGND_WHITE:
case IDM_BKGND_LTGRAY:
case IDM_BKGND_GRAY:
case IDM_BKGND_DKGRAY:
case IDM_BKGND_BLACK:
CheckMenuItem(hMenu,iSelection,MF_UNCHECKED);
iSelection=LOWORD(wParam);
CheckMenuItem(hMenu,iSelection,MF_CHECKED);
SetClassLong(hwnd,GCL_HBRBACKGROUND,
(LONG)GetStockObject(idColor[LOWORD(wParam)-IDM_BKGND_WHITE]));
InvalidateRect(hwnd,NULL,TRUE);
return 0;
case IDM_TIMER_START:
if(SetTimer(hwnd,ID_TIMER,1000,NULL))
{
EnableMenuItem(hMenu,IDM_TIMER_START,MF_GRAYED);
EnableMenuItem(hMenu,IDM_TIMER_STOP,MF_GRAYED);
}
return 0;
}
case IDM_TIMER_STOP:
KillTimer(hwnd,ID_TIMER);
EnableMenuItem(hMenu,IDM_TIMER_START,MF_ENABLED);
EnableMenuItem(hMenu,IDM_TIMER_STOP,MF_GRAYED);
return 0 ;
case IDM_APP_HELP:
MessageBox(hwnd,TEXT("Help not yet implemented!"),szAppName,MB_ICONEXCLAMATION|MB_OK);
return 0;
case IDM_APP_ABOUT:
MessageBox(hwnd,TEXT("Menu Demonstration programe\n")
TEXT("(c)Charles Petzold,1998"),
szAppName,MB_ICONINFORMATION|MB_OK);
return 0;
break;
case WM_TIMER:
MessageBeep(0);
return 0;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
出现
error C2065:
f:\cadan\cadan.c(107) : error C2065: 'IDM_BKGND_WHITE' : undeclared identifier
f:\cadan\cadan.c(107) : error C2099: initializer is not a constant
f:\cadan\cadan.c(117) : error C2065: 'IDM_FILE_NEW' : undeclared identifier
f:\cadan\cadan.c(117) : error C2051: case expression not constant
f:\\cadan\cadan.c(118) : error C2065: 'IDM_FILE_OPEN' : undeclared identifier
f:\cadan\cadan.c(118) : error C2051: case expression not constant
f:\cadan\cadan.c(119) : error C2065: 'IDM_FILE_SAVE' : undeclared identifier
f:\cadan\cadan.c(119) : error C2051: case expression not constant
f:\cadan\cadan.c(120) : error C2065: 'IDM_FILE_SAVE_AS' : undeclared identifier
f:\cadan\cadan.c(120) : error C2051: case expression not constant
f:\cadan\cadan.c(123) : error C2065: 'IDM_APP_EXIT' : undeclared identifier
f:\cadan\cadan.c(123) : error C2051: case expression not constant
f:\cadan\cadan.c(126) : error C2065: 'IDM_EDIT_UNDO' : undeclared identifier
f:\cadan\cadan.c(126) : error C2051: case expression not constant
f:\cadan\cadan.c(127) : error C2065: 'IDM_EDIT_CUT' : undeclared identifier
f:\cadan\cadan.c(127) : error C2051: case expression not constant
f:\cadan\cadan.c(128) : error C2065: 'IDM_EDIT_COPY' : undeclared identifier
f:\cadan\cadan.c(128) : error C2051: case expression not constant
f:\cadan\cadan.c(129) : error C2065: 'IDM_EDIT_PASTE' : undeclared identifier
f:\cadan\cadan.c(129) : error C2051: case expression not constant
f:\cadan\cadan.c(130) : error C2065: 'IDM_EDIT_CLEAR' : undeclared identifier
f:\cadan\cadan.c(130) : error C2051: case expression not constant
f:\cadan\cadan.c(133) : error C2051: case expression not constant
f:\cadan\cadan.c(134) : error C2065: 'IDM_BKGND_LTGRAY' : undeclared identifier
f:\cadan\cadan.c(134) : error C2051: case expression not constant
f:\cadan\cadan.c(135) : error C2065: 'IDM_BKGND_GRAY' : undeclared identifier
f:\cadan\cadan.c(135) : error C2051: case expression not constant
f:\cadan\cadan.c(136) : error C2065: 'IDM_BKGND_DKGRAY' : undeclared identifier
f:\cadan\cadan.c(136) : error C2051: case expression not constant
f:\cadan\cadan.c(137) : error C2065: 'IDM_BKGND_BLACK' : undeclared identifier
f:\cadan\cadan.c(137) : error C2051: case expression not constant
f:\cadan\cadan.c(145) : error C2065: 'IDM_TIMER_START' : undeclared identifier
f:\cadan\cadan.c(145) : error C2051: case expression not constant
f:\cadan\cadan.c(149) : error C2065: 'IDM_TIMER_STOP' : undeclared identifier
f:\cadan\cadan.c(154) : error C2051: case expression not constant
f:\cadan\cadan.c(159) : error C2065: 'IDM_APP_HELP' : undeclared identifier
f:\cadan\cadan.c(159) : error C2051: case expression not constant
f:\cadan\cadan.c(160) : error C2065: 'szAppName' : undeclared identifier
f:\cadan\cadan.c(160) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
f:\cadan\cadan.c(160) : warning C4024: 'MessageBoxA' : different types for formal and actual parameter 3
f:\cadan\cadan.c(162) : error C2065: 'IDM_APP_ABOUT' : undeclared identifier
f:\cadan\cadan.c(162) : error C2051: case expression not constant
f:\cadan\cadan.c(165) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
f:\cadan\cadan.c(165) : warning C4024: 'MessageBoxA' : different types for formal and actual parameter 3
那位好心的大哥帮忙解决