简体   繁体   English

如何在delphi程序中调用TRichEdit方法

[英]How to call TRichEdit methods inside delphi procedures

I'm saluting everyone once again, of course, having another problem while coding. 当然,我再次向所有人致敬,编码时遇到了另一个问题。

I written the following snippet: 我写了以下代码:

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;

The problem is, how can I access those MsgBox's methods inside a procedure ? 问题是,如何在程序中访问那些MsgBox的方法? (program cannot be compiled due "undeclared undentifier MsgBox" (程序无法编译,因为“未声明的标识符MsgBox”

Note: Edit the question if it's not clear enough. 注意:如果问题不够清楚,请编辑问题。 Note2: Also tried to use TChatForm.MsgBox / ChatForm.MsgBox but still unsuccessfull.. 注2:还尝试使用TChatForm.MsgBox / ChatForm.MsgBox但仍然不成功..

Just call procedure with your Richedit as Parameter: 只需使用您的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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM