我用MFC AppWizard(exe)新建了一个工程,然后打开MFC ClassWizard,
其中Class name 选了相应的CView类,
消息选了WM_CREATE,
然后编辑代码,
在其中加入如下代码:
CClient dc(this);理论上说,这会创建与该View关联的DC,
可是编译时出错,出错信息如下:
--------------------Configuration: tester_no3 - Win32 Debug--------------------
Compiling...
tester_no3View.cpp
E:\Program Files\Microsoft Visual Studio\MyProjects\tester_no3\tester_no3View.cpp(132) : error C2065: 'CClient' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\tester_no3\tester_no3View.cpp(132) : error C2146: syntax error : missing ';' before identifier 'dc'
E:\Program Files\Microsoft Visual Studio\MyProjects\tester_no3\tester_no3View.cpp(132) : error C2065: 'dc' : undeclared identifier
Error executing cl.exe.
tester_no3.exe - 3 error(s), 0 warning(s)
为什么会出错?我完全按照书上例子做的。