subaibai 2016-10-23 05:39 采纳率: 50%
浏览 3383
已采纳

vs2012 error C2065: “WndProc”: 未声明的标识符

#include
using namespace std;
#include "Shape.h"
#include "Line.h"
#include "Ellipse.h"
#include "Rectangle.h"
#include
#include
#include
#include
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wndclass;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpszClassName = _T("我的窗体");
wndclass.hInstance = hInstance;
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hIcon = 0;
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndclass.lpszMenuName = 0;
if (RegisterClass(& wndclass)==0)
{
MessageBox(0,_T("注册窗口类失败"),_T("我的窗体"),MB_OK);
return 0;
}
HWND hWnd = CreateWindow(_T("我的窗体"),_T("窗体绘图"),WS_OVERLAPPEDWINDOW,
100, 100,500,400,0,0,hInstance,0
);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
MSG msg;
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return  0;

}
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
CLine Line(50,90,300,90,RGB(0,0,0));
Line.Draw(hdc);
CRectangle rect(102,202,182,282,RGB(192,192,192));
rect.Draw(hdc);
CEllipse ellipse(232,202,312,282,RGB(128,128,0));
ellipse.Draw(hdc);
EndPaint(hWnd, &ps);
}

    break;
case WM_CLOSE:
    PostQuitMessage(0);     
    break;
default:
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
    break;
}
return 0;

}
这是书上的一个程序,按照书上敲的,但是就是没有标识,不知道为什么

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-10-23 08:49
    关注

    在你的源代码前面加上
    LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    要先申明下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器