[DELPHI] - Parsing Hyperlinks-VBForums
Results 1 to 1 of 1

Thread: [DELPHI] - Parsing Hyperlinks

  1. #1

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    [DELPHI] - Parsing Hyperlinks

    Code:
    procedure TForm1.InitRichEditURLDetection(RE: TRichEdit);
    var
      mask: Word;
    begin
      mask := SendMessage(RE.Handle, EM_GETEVENTMASK, 0, 0);
      SendMessage(RE.Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK);
      SendMessage(RE.Handle, EM_AUTOURLDETECT, Integer(True), 0);
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    var
      s: string;
    begin
      InitRichEditURLDetection(RichEdit1);
    
      s:='This will parse www.vbforums.com to show as a URL';
      RichEdit1.Text:= s;
    Code:
    procedure TForm1.WndProc(var Msg: TMessage);
    var
      p: TENLink;
      sURL: string;
      CE : TRichEdit;
    begin
     if (Msg.Msg = WM_NOTIFY) then
     begin
      if (PNMHDR(Msg.lParam).code = EN_LINK) then
      begin
       p := TENLink(Pointer(TWMNotify(Msg).NMHdr)^);
       if (p.Msg = WM_LBUTTONDOWN) then
       begin
        try
         CE := TRichEdit(Form1.ActiveControl);
         SendMessage(CE.Handle, EM_EXSETSEL, 0, Longint(@(p.chrg)));
         sURL := CE.SelText;
         ShellExecute(Handle, 'open', PChar(sURL), 0, 0, SW_SHOWNORMAL);
        except
        end;
       end;
      end;
     end;
    
     inherited;
    end; (* TForm1.WndProc *)
    Last edited by Madboy; Jun 30th, 2005 at 06:03 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.