http://community.csdn.net/Expert/topic/3424/3424735.xml?temp=.6251642
http://community.csdn.net/Expert/topic/3367/3367678.xml?temp=.5284998^_^

解决方案 »

  1.   

    unit LinRichEdit;interfaceuses
      Windows, Messages, SysUtils, Classes, Controls, StdCtrls, ComCtrls;type
      TLinRichEdit = class(TRichEdit)
      private
        FParentWndProc: TWndMethod;
      protected
        procedure CreateWnd; override;
        procedure NewWndProc(var Message: TMessage);
      end;procedure Register;implementation
    uses
      ShellAPI, RichEdit;procedure Register;
    begin
      RegisterComponents('Custom', [TLinRichEdit]);
    end;{ TLinRichEdit }procedure TLinRichEdit.CreateWnd;
    var
      mask: Word;
    begin
      inherited;
      FParentWndProc := Parent.WindowProc;
      Parent.WindowProc := NewWndProc;  mask := SendMessage(Handle, EM_GETEVENTMASK, 0, 0);
      SendMessage(Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK);
      SendMessage(Handle, EM_AUTOURLDETECT, Integer(True), 0);  Text := 'http://www.eastrise.cn/bbsxp/';
    end;procedure TLinRichEdit.NewWndProc(var Message: TMessage);
    var
      p: TENLink;
      sURL: string;
    begin
      if (Message.Msg = WM_NOTIFY) then
        begin
          if PNMHDR(Message.lParam).code = EN_LINK then
            begin
              p := TENLink(Pointer(TWMNotify(Message).NMHdr)^);
              if (p.Msg = WM_LBUTTONDOWN) then
                begin
                  try
                    SendMessage(Handle, EM_EXSETSEL, 0, Longint(@(p.chrg)));
                    sURL := SelText;
                    ShellExecute(Handle, 'open', PChar(sURL), nil, nil, SW_SHOWNORMAL);
                  except
                  end;
                end;
            end;
        end;  FParentWndProc(Message);
    end;end.
      

  2.   

    是不是自动识别URL\EMAIL的代码。。收藏!
      

  3.   

    destructor TLinRichEdit.Destroy;
    begin
      if Assigned(Parent) then
        Parent.WindowProc := FParentWndProc;
      inherited;
    end;看来没有人讨论其他功能了