如何在Edit编辑框中,累加的输入文字?例如:点击一个按钮显示“第一个”。点击另外一个按钮显示“第二个”,但显示这个文字的时候,上次点击的文字保留在框内不变。

解决方案 »

  1.   

    void CMyLogEditDlg::OnButton1() 
    {
    // TODO: Add your control notification handler code here
    CString str;
    GetDlgItem(IDC_EDIT3)->GetWindowText(str);
    str += "第一个";
    SetDlgItemText(IDC_EDIT3,str);
    }void CMyLogEditDlg::OnButton3() 
    {
    // TODO: Add your control notification handler code here
    CString str;
    GetDlgItem(IDC_EDIT3)->GetWindowText(str);
    str += "第二个";
    SetDlgItemText(IDC_EDIT3,str);
    }
      

  2.   

    void CMyLogEditDlg::OnButton1() 
    {
        // TODO: Add your control notification handler code here
        Updatedata();
        CString str;
        GetDlgItem(IDC_EDIT3)->GetWindowText(str);
        str += "第一个";
        SetDlgItemText(IDC_EDIT3,str);
    }void CMyLogEditDlg::OnButton3() 
    {
        // TODO: Add your control notification handler code here
        Updatedata();
        CString str;
        GetDlgItem(IDC_EDIT3)->GetWindowText(str);
        str += "第二个";
        SetDlgItemText(IDC_EDIT3,str);
    }
      

  3.   

    我倒没仔细看
    你用CLASSWIZARD把控件和变量绑定一下啊
    然后使用前UPDATEDATA就哦了
      

  4.   

    通用点的:
    EditAddTail(CEdit* pEdit, LPCTSTR pszText, BOOL bRedo, BOOL bNewLine)
    {
        ASSERT(pEdit && IsWindow(pEdit->GetSafeHwnd());
        if (!(pEdit && IsWindow(pEdit->GetSafeHwnd()))
            return;
        int nLength = pEdit->GetWindowTextLength();
        pEdit->SetSel(nLength, nLength);
        pEdit->ReplaceSel(pszText, bRedo);
        if (bNewLine)
        {
            pEdit->ReplaceSel(_T("\r\n"));
        }
    }