CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);int index = pEdit->GetWindowTextLength(); pEdit->SetSel(index, index);pEdit->ReplaceSel(str);