并不是我不定义,而是因为定义后还是出错。而且我的参考资料上的例程中也没有对pDC进行定义,我也不知道究竟是怎么回事。还请各位大虾们再伤伤脑筋帮帮小弟!另外,这段程序在OnPaint函数中,如果我在程序中添加pDC=GetDC()的话: Compiling... xxxView.cpp D:\mywork\xxx\xxxView.cpp(139) : error C2065: 'pDC' : undeclared identifier D:\mywork\xxx\xxxView.cpp(139) : error C2440: '=' : cannot convert from 'class CDC *' to 'int' This conversion requires a reinterpret_cast, a C-style cast or function-style cast D:\mywork\xxx\xxxView.cpp(145) : error C2227: left of '->BitBlt' must point to class/struct/union Error executing cl.exe.
pDC =GetDC();
如pDC=GetDC();
Compiling...
xxxView.cpp
D:\mywork\xxx\xxxView.cpp(139) : error C2065: 'pDC' : undeclared identifier
D:\mywork\xxx\xxxView.cpp(139) : error C2440: '=' : cannot convert from 'class CDC *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\mywork\xxx\xxxView.cpp(145) : error C2227: left of '->BitBlt' must point to class/struct/union
Error executing cl.exe.
你不能只按书上的例程抄。要动动脑筋。
另外,你也不能只写pDC=GetDC();这样pDC还是没有定义。
试试: CDC *pDC=GetDC();
该成这样试试:
...
CBitmap *pMyBitmap=new CBitmap;
pMyBitmap->LoadBitmap(IDB_MAS);
...