18-05-2011, 10:46 AM
السلام عليكم
بالتوفيق,,
PHP كود :
Const
col: array[1..6] of Dword =($0000FF, $008000, $800000,
$FF0000, $FFFF00, $00FF00);
{$WARNINGS OFF} {$HINTS OFF}
{$O ON}{$OverFlowChecks OFF}
Procedure SearchAndReplace_color(Richedit: TRichEdit; sLookFor, sReplaceWith:string; col: Dword);
{$IF CompilerVersion >= 17}Inline;{$IFEND}
Var
nPos : Integer;
Tmp : String ;
Begin
nPos:= Pos(sLookFor, Richedit.Text);
Tmp:= Richedit.Text;
Richedit.Text := StringReplace(Richedit.Text, sLookFor, sReplaceWith,
[rfReplaceAll, rfIgnoreCase]);
While (nPos > 0) do
Begin
With Richedit do
Begin
SelStart := nPos - 1 ;
SelLength := Length(sReplaceWith);
SelAttributes.Color := col;
End;
nPos := Pos(sLookFor, Tmp);
Tmp := StringReplace(Tmp, sLookFor, sReplaceWith,[rfIgnoreCase]);
End;
End;
I'M Fly Like A G6

