对话框中有一个编辑框控件,控件ID为IDC_EDIT_QUESTION.现在有三个字符数组,str1[100],str2[100],str3[100].
要求把每个字符数组字符数组从内存中显示到编辑框中。我只能把第一个数组显示到编辑框中,代码是GetDlgItem(IDC_EDIT_QUESTION)->SetWindowText(str1);
如果用同样的方法显示第二个数组,此时第一个字符数组将被覆盖。
请高手指教如何在编辑框中显示这三个数组。每个数组占一行,即第一个字符串结束后换行在第二行显示第二个字符串。

解决方案 »

  1.   

    CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_QUESTION);
    int nLen = pEdit->GetWindowTextLength();
    pEdit->SetSel(nLen, nLen);
    pEdit->ReplaceSel(str1);
    nLen = pEdit->GetWindowTextLength();
    pEdit->SetSel(nLen, nLen);
    pEdit->ReplaceSel("\r\n");nLen = pEdit->GetWindowTextLength();
    pEdit->SetSel(nLen, nLen);
    pEdit->ReplaceSel(str2);
    nLen = pEdit->GetWindowTextLength();
    pEdit->SetSel(nLen, nLen);
    pEdit->ReplaceSel("\r\n");nLen = pEdit->GetWindowTextLength();
    pEdit->SetSel(nLen, nLen);
    pEdit->ReplaceSel(str3);手写的代码,要是编译不过就自己改改,大致原理就是这样
      

  2.   

    CString sInfo;
    sInfo.Format("%s\r\n%s\r\n%s",str1,str2,str3);
    GetDlgItem(IDC_EDIT_QUESTION)->SetWindowText(sInfo); 
      

  3.   

    或者用CString把三个str都连接起来然后一次性SetWindowTextCString szText;
    szText.Format("%s\r\n%s\r\n%s", str1, str2, str3);
    GetDlgItem(IDC_EDIT_QUESTION)->SetWindowText(szText);