Eduard
Eduard

Reputation: 3576

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..

Upvotes: 1

Views: 318

Answers (1)

bummi
bummi

Reputation: 27384

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;

Upvotes: 4

Related Questions