Ver Mensaje Individual
  #3  
Antiguo 29-10-2005
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,


Cita:
Empezado por Troy
(...) usa un componente de la libreria SynEdit el cual cumple con lo que necesitas.
Ya lo creo que cumple... acaso hasta demasiado.

A ver qué les parece este componente muy basado en los que se citan y en "TRichEdit":

Código Delphi [-]
 { *********************************************************************** }
 {                                                                         }
 { TDecRichEdit - TRichEdit con soporte para Urls                          }
 {                                                                         }
 { Copyright (c) 2005 dec - dec@ClubDelphi.com                             }
 { bajo la licencia GNU GPL >> ver en www.gnu.org                          }
 {                                                                         }
 { Créditos:                                                               }
 {                                                                         }
 { TJvRichEdit - (Jedi Library) http://www.delphi-jedi.org/                }
 { TRichEditWithHyperlinks (AuRoom Group - http://auroom.obninsk.ru/)      }
 {                                                                         }
 { *********************************************************************** }
 
 unit UDecRichEdit;
 
 interface
 
 uses
   Windows, ComCtrls, RichEdit,
   Classes, Controls, Messages,
   SysUtils, ShellApi;
 
 type
   TDecRichEditClicUrl = procedure(Sender: TObject; const url: string) of object;
 
 type
   TDecRichEdit = class(TRichEdit)
   private
     FAutoAbrirUrls: boolean;
     FOnClicUrl: TDecRichEditClicUrl;
     procedure CNNotify(var Msg: TWMNotify); message CN_NOTIFY;
   protected
     procedure CreateWnd; override;
     procedure AbrirUrl(const url: string);
   public
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
   published
     property OnClicUrl: TDecRichEditClicUrl read FOnClicUrl write FOnClicUrl;
     property AutoAbrirUrls: boolean read FAutoAbrirUrls write FAutoAbrirUrls default true;
   end;
 
 procedure Register;
 
 implementation
 
 { TDecRichEdit }
 
 constructor TDecRichEdit.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
   FAutoAbrirUrls := true;
 end;
 
 destructor TDecRichEdit.Destroy;
 begin
   inherited Destroy;
 end;
 
 procedure TDecRichEdit.AbrirUrl(const url: string);
 begin
   if url <> EmptyStr then
     ShellExecute(Handle, 'open',
       PChar(url), nil, nil, SW_NORMAL);
 end;
 
 procedure TDecRichEdit.CreateWnd;
 begin
   inherited CreateWnd;
   SendMessage(Handle, EM_AUTOURLDETECT, 1, 0);
   SendMessage (Handle, EM_SETEVENTMASK, 0, ENM_LINK);
 end;
 
 procedure TDecRichEdit.CNNotify(var Msg: TWMNotify);
 type
   PENLink = ^TENLink;
 var
   RT: TextRange;
 begin
   case Msg.NMHdr^.code of
     EN_LINK:
       begin
         if (PENLink(Msg.NMHdr).Msg=WM_LBUTTONDOWN) then
         begin
           RT.chrg := PENLink(Msg.NMHdr).chrg;
           GetMem(RT.lpstrText, RT.chrg.cpMax - RT.chrg.cpMin + 2);
           try
             SendMessage(Handle, EM_GETTEXTRANGE, 0, Integer(@RT));
             if Assigned(FOnClicUrl) then
               FOnClicUrl(Self, RT.lpstrText);
             if FAutoAbrirUrls then AbrirUrl(RT.lpstrText);
           finally
             FreeMem(RT.lpstrText);
           end;
         end;
         Msg.Result := 0;
       end;
     else {case}
       inherited;
   end;
 end;
 
 procedure Register;
 begin
   RegisterComponents('Samples', [TDecRichEdit]);
 end;
 
 end.
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita