我想在CRichEditCtrl中删除一整行,pCtrl为CRichEditCtrl的对象指针代码如下:
int i = pCtrl->LineIndex(0);
int k = pCtrl->LineIndex(0) + pCtrl->LineLength(0);
pCtrl->SetSel( i, k );
pCtrl->ReplaceSel("");
为了简单,这段代码只删除第一行,可是实际执行结果却不如预想的一样
经调试发现LineLength()返回的长度不正确
有没有DX知道是为什么啊

解决方案 »

  1.   

    m_EditCtrl.Create(WS_VISIBLE | ES_READONLY | ES_UPPERCASE | ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL , CRect(0,0,0,0), this, IDC_HEX_VIEW))
      

  2.   

    这是我做测试的程序代码:
    char data[]={"00 11 22 55 44 44 77 11 22 55 88 77 44 55\r\n11 11 22 55 44 11 22 55 44 11 25\r\n44 55 55 44 77 \r\n22 11122 33 11 11 22 11 22\r\n"};
    pCtrl->SetSel(-1,-1);
    pCtrl->ReplaceSel(data);
    int i = pCtrl->LineIndex(0);
    int k = pCtrl->LineLength(0);
    int j = pCtrl->LineIndex(0) + k;
    pCtrl->SetSel(i,j);
    pCtrl->ReplaceSel("");
    运行时他删除的并不是一整行,只有其中的一部分
      

  3.   

    经过试验发现下面的问题:
    char data[]={"00 11 22 55 44 44 77 11 22 55 88 77 44 55\n11 11 22 55 44 11 22 55 44 11 25\r\n44 55 55 44 77 \n22 11122 33 11 11 22 11 22\n"};
    如果\n前面的字符数只要多于0x0c,返回的长度就一直是0x0c
    为什么会这样呢
      

  4.   

    我没用RichEdit2.0,应该是1.0的
      

  5.   

    明天改为2.0的看看,难道是1.0的BUG,应该不会吧,网上好像没说哎郁闷