注册 登录
编程论坛 VC++/MFC

edit control如何获取选中的局部文字

仰头的猪 发布于 2013-09-02 15:05, 2597 次点击
edit control如何获取选中的局部文字
2 回复
#2
仰头的猪2013-09-03 07:52
度没有人帮我下,太让我伤心了,附上我找来的代码                    
              int nStart, nEnd;
              CString strTemp;

              m_edFont.GetSel(nStart, nEnd);
              if(nStart == nEnd)
              {
                      strTemp.Format(_T(" 光标在%d" ), nStart);
                      AfxMessageBox(strTemp);
              }
              else
              {
                      //得到edit选中的内容        
               m_edFont.GetWindowText(strTemp);
           strTemp = strTemp.Mid(nStart,nEnd-nStart) ;
            // AfxMessageBox(strTemp);
              }
1