void CtestDlg::OnBnClickedButton1()
{
CString str;
int count = 0;
int length = 0;
GetDlgItemText(IDC_EDIT_1, str);
length = str.GetLength(); //得到了字符的长度
for (int i = 0; i < length; i++) {
if ((byte)str[i] > 0x7F) { //判断单字符是否大于十进制127 是的话那么为中文字符
i++;
}
count++;
}
CString strOut;
strOut.Format(_T("字符长度为 %d 字符个数为%d"), length, count);
SetDlgItemText(IDC_STATIC_2, strOut);
}