Вниз
Скачать: 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.45 MB
Время: 0.009 c
1-1218225470
Delpher!
2008-08-08 23:57
2009.10.04
Как залить изображение на IPicture (с помощью Delphi)?


2-1248952921
xyz
2009-07-30 15:22
2009.10.04
вопрос по поводу пути до БД в ADOConnection


15-1249370873
Kerk
2009-08-04 11:27
2009.10.04
Набор "Юный либерал"


2-1249024539
hinst
2009-07-31 11:15
2009.10.04
wm_needpaint


3-1227778320
Вадим
2008-11-27 12:32
2009.10.04
SELECT к нескольким БД




   Наверх