Prova con questo codice, anche se scandire continuamente le stesse lettere già formattate non è una soluzione performante.
C'è da dire che forse sarebbe meglio evitare la continua selezione di testo, ma forse sarebbe necessario agire con qualche funzione API complessa.codice:var LastSel: Integer; i: Integer; begin MyRichEdit.Hide; try LastSel := MyRichEdit.SelStart; for i := 0 to Length(MyRichEdit.Text) - 1 do begin MyRichEdit.SelStart := i; MyRichEdit.SelLength := 1; case (i+1) mod 3 of 0: if MyRichEdit.SelAttributes.Color <> clGreen then MyRichEdit.SelAttributes.Color := clGreen; 1: if MyRichEdit.SelAttributes.Color <> clBlue then MyRichEdit.SelAttributes.Color := clBlue; 2: if MyRichEdit.SelAttributes.Color <> clRed then MyRichEdit.SelAttributes.Color := clRed; end; MyRichEdit.SelStart:=LastSel; end; finally MyRichEdit.Show; MyRichEdit.SetFocus; end; end;![]()
Ciao!![]()

Rispondi quotando