Das sind Delphi-Grundkenntnisse (Array deklarieren etc).
Etwas Eigeninitiative wäre schon wünschenswert ...
Hier ist es korrekt:
Delphi-Quellcode:
procedure TForm2.JvRichEdit1Change(Sender: TObject);
var
Bitmap: TBitmap;
i,rep,pos :integer;
const
smileys:array [0..1] of string = (':-(', ':-)');
begin
for i := low(smileys) to high(smileys) do
begin
rep := 0;
pos := 0;
while pos <> - 1 do
begin
Pos := jvrichedit1.FindText(smileys[i], rep, Length(JvRichEdit1.Text), []);
rep:=rep + 1;
if Pos <> -1 then
begin
Bitmap := TBitmap.Create;
ImageList1.GetBitmap(i, Bitmap);
JvRichEdit1.SetSelection(Pos, Pos + length(smileys[i]), true);
JvRichEdit1.InsertGraphic(Bitmap, false);
JvRichEdit1.SelStart := Length(JvRichEdit1.Text);
Bitmap.free;
end;
end;
end;
end;