2 hustis1403 HUSTIS1403 于 2016.02.19 16:33 提问

初学windows程序设计,为什么是未定义标识符啊,需要include头文件么?(vs2015)

#include

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = L"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, L"this program requires win32!",szAppName,MB_ICONERROR);
    return 0;
}

hwnd = CreateWindow(szAppName, L"Hello world!", 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 lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;

switch (message)
{
case WM_CREATE:
    MessageBox(hwnd, L"你好,世界", L"窗口第一次创建", MB_OKCANCEL);
    return 0;
case WM_PAINT:
    hdc = BeginPaint(hwnd, &ps);
    GetCilentRect(hwnd, &rect);
    DrawText(hdc, L"Hello world!",-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    EndPaint(hwnd, &ps);
    return 0;
case WM_DESTROY:
    PostQuitMessage(0);
    return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);

}

1>------ 已启动生成: 项目: Win32 wndproc, 配置: Debug Win32 ------
1> 源.cpp
1>e:\c++代码\win32 wndproc\win32 wndproc\源.cpp(55): error C3861: “GetCilentRect”: 找不到标识符
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

1个回答

piaobotudou
piaobotudou   2016.02.19 17:03

因为拼错了
GetClientRect

HUSTIS1403
HUSTIS1403 嗯嗯,看出来了 我拼读就读错了。。。
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!