【问题标题】:How to call TRichEdit methods inside delphi procedures如何在 delphi 程序中调用 TRichEdit 方法
【发布时间】:2012-12-27 17:33:04
【问题描述】:

我再次向大家致敬,当然,在编码时遇到了另一个问题。

我写了以下sn-p:

procedure add_text(text : String);
begin
  MsgBox.SetFocus;
  MsgBox.SelStart := MsgBox.GetTextLen;
  MsgBox.Perform(EM_SCROLLCARET, 0, 0);
  MsgBox.SelText := time_stamp + ' ' + text + #13#10; //time_stamp is a function
end;

问题是,我怎样才能在一个过程中访问那些 MsgBox 的方法呢? (由于“未声明的标识符 MsgBox”,程序无法编译

注意:如果问题不够清楚,请编辑问题。 注意2:也尝试使用 TChatForm.MsgBox / ChatForm.MsgBox 但仍然不成功..

【问题讨论】:

    标签: delphi vcl procedure trichedit


    【解决方案1】:

    只需使用您的 Richedit 作为参数调用程序:

    procedure add_text(MsgBox:TRichedit;const text : String);
    begin
      MsgBox.SetFocus;
      MsgBox.SelStart := MsgBox.GetTextLen;
      MsgBox.Perform(EM_SCROLLCARET, 0, 0);
      MsgBox.SelText := time_stamp + ' ' + text + #13#10; //time_stamp is a function
    end;
    

    【讨论】:

    • 笨蛋你怎么知道 MsgBox 是一个 TRichEdit? :o
    • @jachguate ,帮帮我?这就是问题所在,错误在哪里......
    • @Bummy,没有错,只是问题缺乏上下文,您可能知道这一点,因为您比普通读者更了解该问题。 MsgBox 对我来说听起来像一个 TMessageBox 实例(或类似的东西),但不是一个 TRichEdit 实例,问题并没有说明它是。
    猜你喜欢
    • 1970-01-01
    • 2010-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-18
    • 1970-01-01
    相关资源
    最近更新 更多