这是因为SetDlgItemText()的参数要求一个真正的CString对象,而不是一个字符串数组。
解决办法改编码为多字节,或者用CString变量将ch*构造一下
:代码——————————————————————代码——————
/
// CTestDlg message handlers
// CTestDlg message handlers
void CTestDlg::OnBuz()
{
// TODO: Add your control notification handler code here
CString str;
char ch1[8]={"OPEN"};
char ch2[8]={"CLOSED"};
// ch1[10]=
if(m_chtest==FALSE)
{
str=ch1;
SetDlgItemText(IDC_EDIT1,str);
// GetDlgItem(IDC_EDIT1)->SetWindowText(ch1);
m_chtest=TRUE;
}
else
{
str=ch2;
SetDlgItemText(IDC_EDIT1,str);
// GetDlgItem(IDC_EDIT1)->SetWindowText(ch2);
m_chtest=FALSE;
}
}
{
// TODO: Add your control notification handler code here
CString str;
char ch1[8]={"OPEN"};
char ch2[8]={"CLOSED"};
// ch1[10]=
if(m_chtest==FALSE)
{
str=ch1;
SetDlgItemText(IDC_EDIT1,str);
// GetDlgItem(IDC_EDIT1)->SetWindowText(ch1);
m_chtest=TRUE;
}
else
{
str=ch2;
SetDlgItemText(IDC_EDIT1,str);
// GetDlgItem(IDC_EDIT1)->SetWindowText(ch2);
m_chtest=FALSE;
}
}