void SetSel(
   int nStartChar,
   int nEndChar,
   BOOL bNoScroll = FALSE 
);
nStartChar //参数说明不是 -1开始是选择当前删除吗????
Specifies the starting position. If nStartChar is 0 and nEndChar is –1, all the text in the edit control is selected. If nStartChar is –1, any current selection is removed. 
Example
// The pointer to my edit.
extern CEdit* pmyEdit;// Delete all of the text.
pmyEdit->SetSel(0, -1);
pmyEdit->Clear();

解决方案 »

  1.   

    Clear()方法是删除所选择的文本
    取消选择是 SetSel(-1, 0)
      

  2.   


    SetSel(-1, -1)//是啥意思呢。
      

  3.   

    SetSel(0, -1)//nEndChar是 -1啥意思呢。
      

  4.   

    就是全选的意思:
    nStartChar就是低位,nEndChar就是高位。
      

  5.   

    //0 -1 是全部选中唄? -1,-1 是啥意思呢???  就是全选的意思:
    nStartChar就是低位,nEndChar就是高位。
      

  6.   

    就是全选的意思:
    nStartChar就是低位,nEndChar就是高位。
    如果编译器不报错的话,跟SetSel(-1, 0)是一样的,取消当前选定内容。但有可能nEndChar不能设置为-1
      

  7.   

    edit的光标位置 置到数据头 怎么办就是全选的意思:
    nStartChar就是低位,nEndChar就是高位。
    如果编译器不报错的话,跟SetSel(-1, 0)是一样的,取消当前选定内容。但有可能nEndChar不能设置为-1
      

  8.   

    Quote: 引用 10 楼 mirroatl187 的回复:

    edit的光标位置 置到数据头 怎么办
    什么意思...这跟setsel()有什么关系?
      

  9.   

    setsel(-1,-1) 是什么意思?????? 
      

  10.   


    //下面代码是在文本框,输入10行内容 + 换行
    for(int i = 0 ;i< 10 ;i++)  //不太理解 取消当前选择 是什么意思??? 不太理解
    {
    ((CEdit*)GetDlgItem(IDC_EDIT_INFORMATION))->SetSel(-1,-1);
    ((CEdit*)GetDlgItem(IDC_EDIT_INFORMATION))->ReplaceSel(m_Field_Operate[i].strValue+_T("\r\n"));
    }
    哥,我在八楼已经跟你说了...
    你看清楚了:(0,-1)是全选;(-1,0)是取消当前的选择,那么如果(-1,-1)编译通过的话,应该是跟(-1,0)是一样的作用,是取消当前选择!!!
      

  11.   

    Quote: 引用 16 楼 mirroatl187 的回复:
    //下面代码是在文本框,输入10行内容 + 换行
    for(int i = 0 ;i< 10 ;i++)  //不太理解 取消当前选择 是什么意思??? 不太理解
    {
    ((CEdit*)GetDlgItem(IDC_EDIT_INFORMATION))->SetSel(-1,-1);
    ((CEdit*)GetDlgItem(IDC_EDIT_INFORMATION))->ReplaceSel(m_Field_Operate[i].strValue+_T("\r\n"));
    }这叫选中:
    这个,就叫取消选中:
    而,ReplaceSel()是要替换选中的文本。要实现上述代码功能,你完全可以先把十行数据放在同一个变量里,然后直接SetWindowText()就可以了。