列号即是光标在当前行所在的位置。请各位大虾赐教!
3 个解决方案
#1
行:richedit->CaretPos.y
列:richedit->CaretPos.x
列: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);
}
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
列: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);
}
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);
}