Change underlined ‘red’ words in (underlined) ‘fuchsia’ word

General TRichView support forum. Please post your questions here
Post Reply
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Change underlined ‘red’ words in (underlined) ‘fuchsia’ word

Post by j&b »

Hello,

In a TDBRichViewEdit I have several (different) words, which are underlined and red. After clicking a button I want to change their font.color in fuchsia (underlining remains).

Can someone help me ?
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you need to implement it as an editing operation (that can be undone by user)?
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Post by j&b »

Sergey Tkachenko wrote:Do you need to implement it as an editing operation (that can be undone by user)?
That are hyperlinks (in another way you do – they run fine).
In my TDBRichView-memos I have underlined URLs with font.color:= 3252790 (green).
But all hyperlinks (for URLs) e.g. in word are blue (and underlined).
I thought I do so too. But in the meantime I have created many hyperlinks (URL) in green.
Now I want to change them in blue (without searching them -> about a menuItem).

By the way hyperlinks which call up a program (with parameters) are underlined too, but in another font.color. These hyperlinks (and jumps) are administered in a TMemo (without problems, in an easy way to change …)
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you want to change color of all hyperlinks (without necessity to undo it), use this code

Code: Select all

// assuming DBRichViewEdit1.Style = RVStyle1
if DBRichViewEdit1.CanChange then begin
  for i := 0 to RVStyle1.TextStyles.Count-1 do
    if RVStyle1.TextStyles[i].Jump and (RVStyle1.TextStyles[i].Color = OldColor) then
      RVStyle1.TextStyles[i].Color = NewColor;
  DBRichViewEdit1.Change;
  DBRichViewEdit1.Invalidate;
end;
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Post by j&b »

Hello Sergey,

thank you for your help.

I only have to change 'RVStyle1.TextStyles.Jump' into '(fsUnderline in rvs.TextStyles.style)'.


procedure TForm1.sbTesten1Click(Sender: TObject);
var i: integer;
begin
if memo.CanChange then begin // assuming DBRichViewEdit1.Style = RVStyle1
for i := 0 to rvs.TextStyles.Count-1 do
if (fsUnderline in rvs.TextStyles.style) and (rvs.TextStyles.Color = clFuchsia) then
rvs.TextStyles.Color:= clRed;
memo.Change;
memo.Invalidate;
end;
end;
Post Reply