用C语言写的一个窗口程序,在VS2010旗舰版下编写, 但是在DrawPaint() 里面的TEXT()显示未定义标识符这是为什么啊,我在MessageBox()中用过这个TEXT()啊,自己检查了一下,括号是没问题啊, 但是就是显示未定义标识符!! 求牛人解答一下!!
#include<Windows.h>
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;
MSG msg;
WNDCLASS wndclass;
wndclass.style =CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc =WndProc;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra =0;
wndclass.hInstance =hinstance;
wndclass.hIcon =LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor =LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName =NULL;
wndclass.lpszClassName =szAppName;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("This is program requires Windows NT!"),
szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName,
TEXT("The Hello Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hinstance,
NULL);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM iParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
return 0;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TXET("Hello,Windows XP!"),-1,&rect, //这里的TEXT()显示未定义标识符
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
}
return DefWindowProc(hwnd,message,wParam,iParam);
}
头文件需要包含,具体在那个地方,找一下C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include(不同的版本不太一样)