虾哥们:
    求救了!
如何能判断出Edit中的文本是否处于被选中的状态?
小弟急求。

解决方案 »

  1.   

    TEdit->SelText==TEdit->Text.SubString(TEdit->SelStart,TEdit->SelLength);
      

  2.   

    SelText表示选中的文本,如果SelText==""表示没有选中任何文本
    SelLength表示选中的文本的长度,SelLength==0表示没有选中任何文本
    SelStart表示从第几个字符开始选定,如果SelLength==0那么SelStart就表示光标在该文本框当中最后停留的位置。
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Buffer: PChar;
      Size: Integer;begin  Size := Edit1.SelLength; {Get length of selected text in Edit1}//这里就可以判断了
      Inc(Size); {Add room for null character}
      GetMem(Buffer, Size); {Creates Buffer dynamic variable}
      Edit1.GetSelTextBuf(Buffer,Size); {Puts Edit1.Text into Buffer}
      Edit2.Text := StrPas(Buffer);{Converts Buffer into Pascal-style string}
      FreeMem(Buffer, Size);{Frees memory allocated to Buffer}end;
      

  4.   

    谢几位大哥了。呵呵。我开始以为SelText,SelLength,SelStart这几个属性能只能来设定文字选中。:)
      

  5.   

    不好意思," Kshape(明年回去学C/C++、搞点底层的、不知道好不好?)"
    算错分了.呵呵...该每个人10分才对.
    Kshape大哥的内存管理方式也不错呀!