GetWindowText(IDC_NAME)->SetWindowText(&ch)
这是个邮件收发程序的一部分,底下这个自定义函数完成发送SMTP命令和接收服务器响应码和邮件内容,调试错误如下,希望大家指点下,十分感谢啊!(IDC_NAME是个静态文本控件,IDC_EDIT1是个编辑控件)
G:\C++\复件 邮件收发\Recv.cpp(147) : error C2664: 'void __thiscall CWnd::GetWindowTextA(class CString &) const' : cannot convert parameter 1 from 'const int' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
G:\C++\复件 邮件收发\Recv.cpp(147) : error C2227: left of '->SetWindowTextA' must point to class/struct/union
G:\C++\复件 邮件收发\Recv.cpp(151) : error C2664: 'void __thiscall CWnd::GetWindowTextA(class CString &) const' : cannot convert parameter 1 from 'const int' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
G:\C++\复件 邮件收发\Recv.cpp(151) : error C2227: left of '->SetWindowTextA' must point to class/struct/union
void CRecv::SendCmdAndRecv(int x)
{
n=x;//将参数值赋予该类中的变量n
CString str;//定义字符串用于构造命令
char recvdata[1024]={0},ch[1024],ch2[1024];//接收数据数组
str.Format("retr d%,n");//格式化字符串
str+="\r\n";//添加回车换行符
int s;
s=::socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);//创建套接字
send(s,str.GetBuffer(1),sizeof(str),0);//发送获取邮件命令
if (recv(s,recvdata,1024,0))//接收数据
{
if(recvdata[0]=='O'&&recvdata[1]=='K')//接收成功
{
recvdata[sizeof(recvdata)+1 ]='\0';//将字符数组转换为字符串
mailadd=recvdata;
while(i=mailadd.Find("from:")!=-1 || i<mailadd.Find("\r\n"))//循环查找
{
ch[i++]=recvdata[i++];//拷贝字符
}
GetWindowText(IDC_NAME)->SetWindowText(&ch);//设置发送者邮件地址
if(i=mailadd.Find("\n")!=-1)//查找空行
{
ch2[i++]=recvdata[i++];//拷贝字符
GetWindowText(IDC_EDIT1)->SetWindowText(&ch);//显示邮件内容
}
}
else
{MessageBox("接收失败!");
}
}
}