请帮忙看下这段代码,编译器不识CWnd
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
}
错误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 公共控件的支持