تلوين البحث و التغيير Search And Replace
#1
كيف نصحح هذه التابع لكي يعمل SearchAndReplace
مع تميز القيمة المستبدلة بلون معين
انا حاولت اكتب ولكن بأخطاء
ممكن تحاولوا معي
PHP كود :
const
  
col: array[0..5] of TColor = (clRed, clGreen, clNavy, clBlue, clAqua, clLime);

procedure SearchAndReplace_color(richedit: TRichEdit; sLookFor, sReplaceWith:
  
string; col: TColor);
var
  
nPos, nLenLookFor, nLenReplaceWith: integer;
  
sSrc: string;
begin
  sSrc 
:= richedit.Text;
  
nPos := Pos(sLookFor, sSrc);
  
nLenLookFor := Length(sLookFor);
  
nLenReplaceWith := Length(sReplaceWith);
  while (
nPos > 0) do
  
begin
    
//   richedit.Text := sSrc;
    
Delete(sSrc, nPos, nLenLookFor);
    
Insert(sReplaceWith, sSrc, nPos);
    
with richedit do
    
begin

      
//      SelText := sReplaceWith;
      
SelStart := nPos ;
      
SelLength := nLenReplaceWith;
      
SelAttributes.Color := col;

    
end;
    
//

    //
    
nPos := Pos(sLookFor, sSrc);
    
//    Delete(sSrc, nPos, nLenLookFor);
    //    Insert(sReplaceWith, sSrc, nPos);
  
end; 

كود :
procedure TForm1.btn1Click(Sender: TObject); begin SearchAndReplace_color(redt1, 'SDK', 'RRR', Col[0]); end;

مثال
PHP كود :
Here we provide you SDK links to 
the 
latest SDK updates 
for different 
satellite SDK in order to SDK 
your box updated with the 
permanently SDK satellite 
channel SDK
. 
الرد


الردود في هذا الموضوع
تلوين البحث و التغيير Search And Replace - بواسطة cargem - 17-05-2011, 04:11 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم