关于超想
本站导航
邮件列表
  首页 | 本站产品 | Delphi资料 | 免费资源 | 程序人生 | 软件工程 | 网站设计 | 推荐网站
你所在的位置 -> 主页 -> 超想软件 -> 编程资料 -> delphi -> 开发技巧 -> 构件使用 ->详细
相关内容  
 
 
在Delphi程序中应用IE浏览器控件
 
【新品推荐】

  详细内容
 

改变RichEdit的游标位置
作者: 评价: 上站日期: 2002-02-14
内容说明:
来源:

// 指定输入游标的位置
procedure SetCaret(RTF: TRichEdit; var Row, Col: word);
var
i, iStopLine, iSelStart: integer;
begin
if (RTF = nil) then Exit;
if Row = 0 then Row := 1;
if Col = 0 then Col := 1;

// 到第 Row 列, Col 行共几个字元
iStopLine := Row - 1;
iSelStart := 0;
for i := 0 to RTF.Lines.Count - 1 do
begin
if i = iStopLine then
begin
if Length(RTF.Lines[i]) > = Col then
Inc(iSelStart, Col)
else
Inc(iSelStart, Length(RTF.Lines[i]) + 2);
Break;
end;
Inc(iSelStart, Length(RTF.Lines[i]) + 2);
end;
if iSelStart >  0 then Dec(iSelStart);

// 以设定标记的方式指定游标位置
SendMessage(RTF.Handle, EM_SETSEL, iSelStart, iSelStart);

// 再次侦测游标位置
Row := SendMessage(RTF.Handle, EM_LINEFROMCHAR, RTF.SelStart, 0);
Col := RTF.SelStart - SendMessage(RTF.Handle, EM_LINEINDEX, Row, 0);

// 卷到游标所在位置
SendMessage(RTF.Handle, EM_SCROLLCARET, 0, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
iRow, iCol: word;
begin
iRow := 17;
iCol := 3;
SetCaret(RichEdit1, iRow, iCol);
RichEdit1.SetFocus;
end;

 
你所在的位置 -> 主页 -> 超想软件 -> 编程资料 -> delphi -> 开发技巧 -> 构件使用 ->详细
  首页 | 本站产品 | Delphi资料 | 免费资源 | 程序人生 | 软件工程 | 网站设计 | 推荐网站
声明:本站内容除注明原创以外均从网上摘抄,如有侵权请指明。
  如果您对我们的网站有什么意见或者建议,请与我们联系
powered by 建站易上手- V2.0