MFC入门示例之静态文本框、编辑框

点击按钮计算文本框中文本长度

void CMFCApplication1Dlg::OnBnClickedButton1()
{
    CString strInput;
    GetDlgItemText(IDC_EDIT_INPUT, strInput);
    int nLen = strInput.GetLength();

    CString strOutput;
    strOutput.Format(TEXT("字符串长度:%d,字符个数:%d"), nLen, nLen); 
    SetDlgItemText(ID_STATIC_OUTPUT, strOutput);
}

猜你喜欢

转载自www.cnblogs.com/runtimeexception/p/9208458.html