1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| procedure TForm1.Button1Click(Sender: TObject);
var
P: integer;
Bmp: TBitmap;
S, SPos: string;
begin
S:= edit1.text;
SPos:= edit2.text; // le sous-texte à trouver
Bmp:= TBitmap.Create;
Bmp.Width:= 200;
Bmp.Height:= 21;
Bmp.Canvas.Font.Assign(Font);
P:= Pos(SPos, S);
if P > 0 then
TextMultiColors([Copy(S,1,P-1), Copy(S,P,Length(SPos)), Copy(S,P+Length(SPos),MAXINT)],
[clBlack,clBlue,clBlack], Bmp, clSilver)
else
TextMultiColors([S],[clBlack], Bmp, clSilver);
Canvas.Draw(100,100,Bmp);
Bmp.Free;
end; |
Partager