Frage

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

War es hilfreich?

Lösung

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;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top