怎样获得richedit控件当前光标所在位置的行号各列号?

时间:2022-08-08 10:32:44
如何知道richedit控件当前光标所在位置的行号各列号?
列号即是光标在当前行所在的位置。请各位大虾赐教!

3 个解决方案

#1


行:richedit->CaretPos.y
列:richedit->CaretPos.x

#2


thanks!接分。

#3


void __fastcall TForm1::RichEdit1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
int Line=SendMessage(RichEdit1->Handle,EM_LINEFROMCHAR,RichEdit1->SelStart,0);
int Col=SendMessage(RichEdit1->Handle,EM_LINEINDEX,Line,0);
Label1->Caption=IntToStr(Line+1)+AnsiString(":")+IntToStr(RichEdit1->SelStart-Col+1);

}

#1


行:richedit->CaretPos.y
列:richedit->CaretPos.x

#2


thanks!接分。

#3


void __fastcall TForm1::RichEdit1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
int Line=SendMessage(RichEdit1->Handle,EM_LINEFROMCHAR,RichEdit1->SelStart,0);
int Col=SendMessage(RichEdit1->Handle,EM_LINEINDEX,Line,0);
Label1->Caption=IntToStr(Line+1)+AnsiString(":")+IntToStr(RichEdit1->SelStart-Col+1);

}