Показать сообщение отдельно
  #9  
Старый 26.06.2013, 12:27
Аватар для AlexandrV
AlexandrV AlexandrV вне форума
Начинающий
 
Регистрация: 10.02.2013
Сообщения: 197
Версия Delphi: XE3
Репутация: -624
По умолчанию

Почему этот код

Код:
procedure TForm2.RED1KeyPress(Sender: TObject; var Key: Char);
var stroca:integer;
  i:Integer;
begin
  case key of
    #32:begin
      if Form2.RED1.Text[Length(Form2.RED1.Text)]=#32 then System.exit else begin
        stroca:=Length(Form2.RED1.Text);
        repeat
          stroca:=stroca-1;
        until (Form2.RED1.Text[stroca]=#32) or (stroca=0);
        Form2.RED1.SelStart:=stroca;
        Form2.RED1.SelLength:=Length(Form2.RED1.Text);
        for i := 0 to Length(ColorText) do begin
          if AnsiUpperCase(Form2.RED1.SelText) = ColorText[i].ColText then begin
            Form2.RED1.SelAttributes.Color:=ColorText[i].ColColor;
            Form2.RED1.SelAttributes.Style:=ColorText[i].ColFontStyle;
          end
          else begin
            Form2.RED1.SelAttributes.Color:=Form2.FontDialog1.Font.Color;
            Form2.RED1.SelAttributes.Style:=Form2.FontDialog1.Font.Style;
          end;
          Form2.RED1.SelStart:=Length(Form2.RED1.Text);
        end;
      end;
    end;
  end;
end;

ColorText[0].ColText:=AnsiUpperCase(PRK1);
  ColorText[0].ColColor:=ClBlue;
  ColorText[0].ColFontStyle:=[fsbold];
  ColorText[1].ColText:=':';
  ColorText[1].ColColor:=clGreen;
  ColorText[1].ColFontStyle:=[fsBold];
  ColorText[2].ColText:='|';
  ColorText[2].ColColor:=ClRed;
  ColorText[2].ColFontStyle:=[fsBold];

ColorText:Array[0..2] of TColorText;

Type TColorText=record
  ColText:String;
  ColColor:TColor;
  ColFontStyle:TFontStyles;
end;

красит только 1 слово Begin
Ответить с цитированием