- 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分相赠...
错误提示如下:
错误 1 error C3872: “0x3000”: 此字符不允许在标识符中使用 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 161
错误 2 error C2065: “ CWnd”: 未声明的标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 161
错误 3 error C2065: “pMainWnd”: 未声明的标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp
错误 6 error C2146: 语法错误 : 缺少“;”(在标识符“ ”的前面) f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 163
错误 7 error C3861: “ while”: 找不到标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 162
错误 8 error C2065: “ ”: 未声明的标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 163
错误 9 error C2143: 语法错误 : 缺少“;”(在“{”的前面) f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 163
错误 12 error C2065: “ HWND”: 未声明的标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 164
错误 13 error C2146: 语法错误 : 缺少“;”(在标识符“hWnd”的前面) f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 164
错误 14 error C2065: “hWnd”: 未声明的标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 164
错误 15 error C2065: “hNext”: 未声明的标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 164
错误 18 error C2065: “ hWnd”: 未声明的标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 165
错误 19 error C2227: “->m_hWnd”的左边必须指向类/结构/联合/泛型类型 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 16
错误 22 error C2065: “ pMainWnd”: 未声明的标识符 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\messagedlg.cpp 166
错误 23 error C2227: “->GetWindowTextW”的左边必须指向类/结构/联合/泛型类型 f:\documents and settings\administrator\my documents\visual studio 2005\projects\message\message\