16,471
社区成员
发帖
与我相关
我的任务
分享
void CDialogSampleDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
int nStart, nEnd;
CString strTemp;
m_edit1.GetSel(nStart, nEnd);
if(nStart == nEnd)
{
strTemp.Format(_T("光标在%d"), nStart);
AfxMessageBox(strTemp);
}
else
{
m_edit1.GetWindowText(strTemp);
strTemp = strTemp.Mid(nStart,nEnd-nStart) ;
AfxMessageBox(strTemp);
}
}
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
ASSERT(pEdit && pEdit->GetSafeHwnd());
int start = 0;
int end = 0;
pEdit->GetSel(start, end);
CString strText(_T(""));
pEdit->GetWindowText(strText);
strText = strText.Mid(start, end - start);
AfxMessageBox(strText);