频道分类

Delphi 如何在TMemo,TEdit或TRichEdit中获得插入符的位置

作者:admin 来源: 日期:2020/9/15 13:51:32 人气: 标签:

 
TRichEdit:

var
  pt: TPoint;
begin
  with richedit1 do
  begin
    Perform(messages.EM_POSFROMCHAR, WPARAM(@pt), selstart);
    label1.caption := Format('(%d, %d)', [pt.x, pt.y]);
  end;
end;
TMemo and TEdit

var
  r: LongInt;
begin
  with memo1 do
  begin
    r := Perform(messages.EM_POSFROMCHAR, selstart, 0);
    if r >= 0 then
    begin
      label1.caption := IntToStr(HiWord(r));
      label2.caption := IntToStr(LoWord(r));
    end;  
  end;
end;

上一篇:Delphi 如何清空Image1下一篇:没有资料