Home > Back-end >  Function that is defined as the following, need two values! Can't express! Is a string, a to co
Function that is defined as the following, need two values! Can't express! Is a string, a to co

Time:11-13

Function that is defined as the following, need two values! Can't express! Is a string, a to color!
[Delphi] plain text view copying code

 
Var
FoundAt: LongInt;
StartPos ToEnd: Integer;
Str: string;
The begin
With RichEdit1 do
The begin
Str:='52 pojie';/////11111111111111111111111111111111111111111111111111111111111111111
If SelLength & lt;> 0 then
StartPos:=SelStart + SelLength
The else
StartPos:=0;
ToEnd:=Length (Text) - StartPos;
While FoundAt & lt;> 1 do
The begin
FoundAt:=FindText (Str, StartPos ToEnd, [stMatchCase]);
If FoundAt & lt;> 1 then
The begin
SelStart:=FoundAt;
ShowMessage (IntToStr (SelStart));
SelLength:=Length (Str);
SelAttributes. Color:=clred;//////////////////222222222222222222222222222222222222222222
end;
StartPos:=FoundAt + 1;
ToEnd:=Length (Text) - StartPos;
end;
end;
end;

CodePudding user response:

Procedure RichEditSetTextColor (ARichEdit: TRichEdit; Const AText: string; AColor: TColor);
Var
FoundAt: LongInt;
StartPos ToEnd: Integer;
The begin
With ARichEdit do
The begin
//Str='52 pojie';//delete the line
//... The rest of the copy
FoundAt:=FindText (AText StartPos, ToEnd, [stMatchCase])
//...
SelAttributes. Color:=AColor;
//... ;
end;
  • Related