![]() |
"BB-Codes" in JvRichEdit?
Hallo,
ich möchte gerne eine Art von BB-Codes in ein JvRichEdit einbauen. Also wenn [b ]Irgendein Text[/b] eingegeben wird, soll Irgendein Text angezeigt werden. wisst ihr wie ich das am geschicktesten löse? MfG Angtel4585 PS: Mit diesem Code bau ich Smilies ein, vllt muss man den nur modifizieren?
Delphi-Quellcode:
procedure TtfMain.RichEditChange(Sender: TObject); var B : TBitMap; pos : Integer; i : integer; begin LockWindowUpdate(Handle); try try B:=TBitmap.Create; try for i:= 0 to Pred(Length(SMILEY_FIELD)) do begin pos:=RichEdit.FindText(SMILEY_FIELD[i], 0, Length(RichEdit.Text),[]); ImageList.GetBitmap(i,B); b.TransparentColor:=clWhite; b.Transparent:=True; while Pos >= 0 do begin RichEdit.SetSelection(Pos,Pos + Length(SMILEY_FIELD[i]),true); RichEdit.InsertGraphic(B,false); RichEdit.SelStart:=Length(RichEdit.Text); Pos:=RichEdit.FindText(SMILEY_FIELD[i], Pos + Pred(Length(SMILEY_FIELD[i])), Length(RichEdit.Text),[]); end; end; finally B.Free; end; except end; finally LockWindowUpdate(0); end; end; |
Re: "BB-Codes" in JvRichEdit?
So ich hab den Code soweit modifiziert, hab jetzt allerdings das Problem, das ich den Alten Text innerhalb der Codes, inklusive der Codes selbst da rauslöschen muss:
Delphi-Quellcode:
Also kann mir jemand sagen wie ich da den selektierten Text lösche? Ich bin echt am verzweifel.. ich find einfach keine Methode.. das einfach Delete funzt nicht, da ich da ne Variable übergeben muss, allerdings iss wenn ich den text vorher in ne Variable speicher die Formatierung futsch :(
procedure TtfMain.reAllyComChange(Sender: TObject);
var B : TBitMap; pos,pos2,pos3 : Integer; i : integer; ltext,ltext2 : string; begin LockWindowUpdate(Handle); reAllyCom.OnChange:=nil; try try B:=TBitmap.Create; try for i:= 0 to Pred(Length(SMILEY_FIELD)) do begin pos:=reAllyCom.FindText(SMILEY_FIELD[i], 0, Length(reAllyCom.Text),[]); ilSmilies.GetBitmap(i,B); b.TransparentColor:=clWhite; b.Transparent:=True; while Pos >= 0 do begin reAllyCom.SetSelection(Pos,Pos + Length(SMILEY_FIELD[i]),true); reAllyCom.InsertGraphic(B,false); reAllyCom.SelStart:=Length(reAllyCom.Text); Pos:=reAllyCom.FindText(SMILEY_FIELD[i], Pos + Pred(Length(SMILEY_FIELD[i])), Length(reAllyCom.Text),[]); end; end; pos:=reAllyCom.FindText('[b]',0,Length(reAllyCom.Text),[]); pos2:=reAllyCom.FindText('[/b]',pos+3,Length(reAllyCom.Text),[]); while (Pos >=0)and(pos2>=0) do begin ltext:=reallycom.GetTextRange(pos+3,pos2); reallycom.SetSelection(pos,pos2+4,true); //Hier muss der Text rausgelöscht werden! reAllyCom.InsertFormatText(pos,ltext,[fsbold]); pos2:=reAllyCom.FindText('[/b]',pos+3,Length(reAllyCom.Text),[]); pos:=reAllyCom.FindText('[b]',pos+3,Length(reAllyCom.Text),[]); end; finally B.Free; end; except Beep; end; finally reAllyCom.OnChange:=reAllyComChange; LockWindowUpdate(0); end; end; |
Re: "BB-Codes" in JvRichEdit?
Hi
Zitat:
Delphi-Quellcode:
RichEdit.SelText := '';
|
Re: "BB-Codes" in JvRichEdit?
:firejump: JUHUUU ES FUNGSIONIERT :dp:
Thx Matze :thumb: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:35 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz