首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

请帮忙看下这段代码,编译器不识CWnd,该怎么处理

2012-04-05 
请帮忙看下这段代码,编译器不识CWndC/C++ codevoid CMySMSDlg:: QQSendMessage(){ CString str CWnd* pMa

请帮忙看下这段代码,编译器不识CWnd

C/C++ code
void CMySMSDlg:: QQSendMessage() 
{
 CString str;
 CWnd* pMainWnd = AfxGetMainWnd()->GetWindow(GW_HWNDFIRST);
 while (pMainWnd)
 {
  HWND hWnd,hNext;
  hWnd = pMainWnd->m_hWnd;
  pMainWnd->GetWindowText(str);
  if(str.Find ("聊天")>-1){//找到聊天主窗口Begin
   //找RichEdit
   hWnd=FindWindowEx(pMainWnd->m_hWnd,NULL,"#32770",NULL);
   pMainWnd = CWnd::FromHandle(hWnd);
   hWnd=FindWindowEx(pMainWnd->m_hWnd,NULL,"AfxWnd42",NULL);
   CWnd* pChildWnd=CWnd::FromHandle(hWnd);
   int nLen = str.GetLength ();
   hNext = FindWindowEx(pChildWnd->m_hWnd,NULL,"RICHEDIT",NULL);
   if(hNext){//找到消息填写控件
    CRichEditCtrl* pRich=(CRichEditCtrl*)(CWnd::FromHandle(hNext));
    pRich->GetWindowText (str);
    pRich->SetSel (nLen,nLen);
    pRich->ReplaceSel ("成都外国语学校");//填上将要发送的内容
   }else return;
   //找消息发送按钮
   hWnd=FindWindowEx(pMainWnd->m_hWnd,NULL,NULL,NULL);
   while (hWnd) {
    pChildWnd=CWnd::FromHandle(hWnd);
    pChildWnd->GetWindowText(str);
    if(str.Find ("发送")>-1){
     pChildWnd->SendMessage (BM_CLICK);//发送
     return;// 退出
    }
    hWnd=FindWindowEx(pMainWnd->m_hWnd,hWnd,NULL,NULL);
   }
   return;
  }//找到聊天主窗口End
  else pMainWnd = pMainWnd->GetWindow(GW_HWNDNEXT); //继续找
 }//While
}



已经包含了头文件:afxwin.h

初学VC......跪求指点....200分相赠...

错误提示如下:

错误1error C3872: “0x3000”: 此字符不允许在标识符中使用f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp161
错误2error C2065: “ CWnd”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp161
错误3error C2065: “pMainWnd”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp
错误6error C2146: 语法错误 : 缺少“;”(在标识符“ ”的前面)f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp163
错误7error C3861: “ while”: 找不到标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp162
错误8error C2065: “ ”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp163
错误9error C2143: 语法错误 : 缺少“;”(在“{”的前面)f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp163
错误12error C2065: “  HWND”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp164
错误13error C2146: 语法错误 : 缺少“;”(在标识符“hWnd”的前面)f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp164
错误14error C2065: “hWnd”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp164
错误15error C2065: “hNext”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp164

错误18error C2065: “  hWnd”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp165
错误19error C2227: “->m_hWnd”的左边必须指向类/结构/联合/泛型类型f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp16
错误22error C2065: “  pMainWnd”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp166
错误23error C2227: “->GetWindowTextW”的左边必须指向类/结构/联合/泛型类型f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\



错误26error C2664: “int ATL::CStringT<BaseType,StringTraits>::Find(wchar_t,int) throw() const”: 不能将参数 1 从“const char [5]”转换为“wchar_t”f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp167
错误27error C2143: 语法错误 : 缺少“;”(在“{”的前面)f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp167
错误28error C3861: “  if”: 找不到标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp167

错误35error C2065: “   ”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp169
错误36error C2146: 语法错误 : 缺少“;”(在标识符“   hWnd”的前面)f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp169
错误37error C2065: “   hWnd”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp169
错误38error C2227: “->m_hWnd”的左边必须指向类/结构/联合/泛型类型f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp169
错误39error C3872: “0x3000”: 此字符不允许在标识符中使用f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp170

错误42error C2065: “   pMainWnd”: 未声明的标识符f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp170

[解决办法]
源文件里有不应该出现的字符

[解决办法]
有时C++编译器提示的错误实在是让人摸不着头脑。LZ应该从第一个错误找原因,往往第一个错误解决了,其它的错误都会消失。
[解决办法]
vc.net里没那个CWnd类,回到6.0试试。花点时间了解一下新版本。
[解决办法]
#include <afxwin.h> // MFC 核心组件和标准组件
#include <afxext.h> // MFC 扩展

#include <afxcmn.h>// MFC 对 Windows 公共控件的支持

热点排行