Вниз
Скачать: CL | DM;

richedit.selattr   Найти похожие ветки 

← →
webpauk ©   (2009-08-03 11:47) [0]

Чувствую себя дебилом:

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, ComCtrls;

type
 TForm1 = class(TForm)
   Button1: TButton;
   RichEdit1: TRichEdit;
   procedure Button1Click(Sender: TObject);
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
const
 cArrColor: array[Boolean] of TColor = (clRed, clBlue);
 cArrText: array[Boolean] of String = ("Hello", "Bye");
var
 fWidth: Integer;
 fSelStart: Integer;
 fText: String;
begin
 fSelStart:=RichEdit1.SelStart;
 fText:=cArrText[Boolean(TButton(Sender).Tag)];
 fWidth:=Length(fText);

 RichEdit1.Text:=copy(RichEdit1.Text, 1, fSelStart)+fText+copy(RichEdit1.Text, fSelStart+1, Length(RichEdit1.Text)-fSelStart);
 RichEdit1.SelStart:=fSelStart;
 RichEdit1.SelLength:=fWidth;
 RichEdit1.SelAttributes.Color:=cArrColor[Boolean(TButton(Sender).Tag)];

 RichEdit1.SelStart:=fSelStart+fWidth;
 RichEdit1.SetFocus;

 TButton(Sender).Tag:=Integer(not Boolean(TButton(Sender).Tag));
end;

end.


почему один раз меняется оформление всего текста, а один раз - только части?


← →
Leonid Troyanovsky ©   (2009-08-03 13:14) [1]


> webpauk ©   (03.08.09 11:47)  

>  RichEdit1.Text:=copy(RichEdit1.Text, 1, fSelStart)+fText+copy(RichEdit1.
> Text, fSelStart+1, Length(RichEdit1.Text)-fSelStart);

RichEdit1.SelText:= fText;

--
Regards, LVT.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.44 MB
Время: 0.01 c
3-1227778244
vegarulez
2008-11-27 12:30
2009.10.04
Вопрос про ZeosDBO. (Zquery.Fields[i].AsDatetime)


2-1248942126
KK
2009-07-30 12:22
2009.10.04
Строку в список


1-1218618200
dmitry_12_08_74
2008-08-13 13:03
2009.10.04
Подскажите, как определить, над каким окном находится мышь


2-1244576320
новичок13
2009-06-09 23:38
2009.10.04
прозрачна форма но не прозрачная картинка


15-1249386581
b/@.
2009-08-04 15:49
2009.10.04
Тяжело ли переходить от одиночной разработки к колективной...




   Наверх