注册 登录
编程论坛 C++教室

怎么办?

china25qd 发布于 2007-09-13 20:46, 407 次点击

我要把一个文本框里输入的信息通过按钮转移到另一个文本筐里:
void CMy20070907_wuDlg::OnBtnand() //"And"
{
// TODO: Add your control notification handler code here
CString str;
m_Txtinput.GetWindowText(str);
m_Txtinput.SetWindowText(str + CString("&"));

}

void CMy20070907_wuDlg::OnBtnimp() // "->"
{
// TODO: Add your control notification handler code here
CString str;
m_Txtinput.GetWindowText(str);
m_Txtinput.SetWindowText(str + CString("->"));

}

void CMy20070907_wuDlg::OnBtnminus() //"-"
{
// TODO: Add your control notification handler code here
CString str;
m_Txtinput.GetWindowText(str);
m_Txtinput.SetWindowText(str + CString("-"));

}

void CMy20070907_wuDlg::OnBtnor() // "||"
{
// TODO: Add your control notification handler code here
CString str;
m_Txtinput.GetWindowText(str);
m_Txtinput.SetWindowText(str + CString("||"));

}

void CMy20070907_wuDlg::OnChangeTxtInput()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

}

void CMy20070907_wuDlg::OnbtnEnt() //">>"
{
// TODO: Add your control notification handler code here
CString str1, str2;
m_Editcondition.GetWindowText(str2);
m_Editcondition.SetWindowText(str2 + m_Txtinput.GetWindowText(str1));
}

然后error中说:error C2679: binary '+' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
怎么办呢?

3 回复
#2
海子星竹2007-09-14 12:18

合并字符串是不能用加减号的
用strcat来连接两个字符串

#3
PcrazyC2007-09-14 18:29
你去查下MSDN,看看GetWindowText的返回值是什么就知道了,将这一句换成两句:

m_Txtinput.GetWindowText(str1);
m_Editcondition.SetWindowText(str2 + str1);
#4
china25qd2007-09-14 21:43

谢谢楼上

1