简体   繁体   中英

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 ? (program cannot be compiled due "undeclared undentifier MsgBox"

Note: Edit the question if it's not clear enough. Note2: Also tried to use TChatForm.MsgBox / ChatForm.MsgBox but still unsuccessfull..

Just call procedure with your Richedit as Parameter:

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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