1

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

Eduard
  • 3,395
  • 8
  • 37
  • 62

1 Answers1

4

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;
bummi
  • 27,123
  • 14
  • 62
  • 101
  • bummy how do you know MsgBox is a TRichEdit? :o – jachguate Dec 28 '12 at 02:15
  • 1
    @jachguate , help me? That's what the questions was about, where is the mistake ... – bummi Dec 28 '12 at 08:40
  • @Bummy, there's no mistake, just the question lacks context and you may know that because you know more than the casual reader about the problem. MsgBox sounds like a TMessageBox instance (or something like that) to me, but not a TRichEdit instance, and the question doesn't state it is. – jachguate Dec 30 '12 at 04:09