按你的需要作时当修改:<br>procedure TForm1.UpdateCursorPos;<br>var<br> CharPos: TPoint;<br>begin<br> CharPos.Y := SendMessage(Richedit1.Handle, EM_EXLINEFROMCHAR, 0, Richedit1.SelStart);<br> CharPos.X := (Richedit1.SelStart - SendMessage(Richedit1.Handle, EM_LINEINDEX, CharPos.Y, 0));<br> Inc(CharPos.Y);<br> Inc(CharPos.X);<br> //可赋给全局变量<br> StatusBar1.Panels[0].Text := Format('Line: %3d Col: %3d', [CharPos.Y, CharPos.X]);<br> StatusBar1.Panels[1].Text := 'SelStart:' + InttoStr(Richedit1.SelStart);<br>end;<br>