// Editor 为TRichEdit
// Statusbar 为状态栏TStatusbar
procedure TMainForm.UpdateCursorPos;
var
CharPos: TPoint;
s:widestring;
begin
CharPos.Y := SendMessage(Editor.Handle, EM_EXLINEFROMCHAR, 0,
Editor.SelStart);
CharPos.X := (Editor.SelStart -
SendMessage(Editor.Handle, EM_LINEINDEX, CharPos.Y, 0));
s:=copy(editor.Lines [CharPos.Y],1,CharPos.X);
CharPos.x:=Length(s);
Inc(CharPos.Y); //将第一行由0变为1
Inc(CharPos.X); //将第一列由0变为1
StatusBar.Panels[0].Text := Format(sColRowInfo, [CharPos.Y, CharPos.X]);
end;