trichview.com

trichview.support.examples




Example: target-dependent drawing of hyperlinks


Return to index


Author

Message

Sergey Tkachenko

Posted: 09/22/2004 19:07:25


Example: This code uses TRVStyle.OnDrawStyleText to make the following

effects:

- all hyperlinks are underlined regardless of their character attributes

- hyperlinks with empty target has light gray background

- links to e-mails are blue, to urls are green, others are gray.


procedure TForm3.RVStyle1DrawStyleText(Sender: TRVStyle; const s: String;

  Canvas: TCanvas; StyleNo, SpaceBefore, Left, Top, Width, Height: Integer;

  DrawState: TRVTextDrawStates; var DoDefault: Boolean);

var target: String;

begin

  if Sender.TextStyles[StyleNo].Jump then begin

    Canvas.Font.Style := Canvas.Font.Style+[fsUnderline];

    if rvtsSelected in DrawState then

      exit;

    target := PChar(TCustomRVData(Sender.RVData).GetItemTag(Sender.ItemNo));

    if target='' then begin

      Canvas.Brush.Color := clSilver;

      exit;

    end;

    if RVIsEmail(target) then

      Canvas.Font.Color := clBlue

    else if RVIsURL(target) then

      Canvas.Font.Color := clGreen

    else

      Canvas.Font.Color := clGray;

  end;

end;


Note: these changes are not saved in RTF/HTML.





Powered by ABC Amber Outlook Express Converter