GetTextPos(RichEdit1.Handle, RichEdit1.SelStrat, RichEdit1.SelLength);function GetTextPos(P: Hwnd; Ss, Sl: Longint): TPoint;
var
Row,col : integer;
begin
col := SendMessage(P,EM_LINEINDEX,-1,0);
row := SendMessage(P,EM_LINEFROMCHAR,col,0);
if col > Ss then
col := Ss + Sl - col
else
col := Ss - col;
result.x := col + 1;
result.y := row + 1;
end;
var
Row,col : integer;
begin
col := SendMessage(P,EM_LINEINDEX,-1,0);
row := SendMessage(P,EM_LINEFROMCHAR,col,0);
if col > Ss then
col := Ss + Sl - col
else
col := Ss - col;
result.x := col + 1;
result.y := row + 1;
end;
把richedit的字体设为和form的字体一样,然后
canvas.textwidth('t')
canvas.textheight('t')