Guest User

Untitled

a guest
Oct 4th, 2011
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.43 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, ComCtrls, ShellApi, RichEdit, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     RichEdit1: TRichEdit;
  12.     procedure FormCreate(Sender: TObject);
  13.   private
  14.     { Private declarations }
  15.   public
  16.     { Public declarations }
  17.   protected
  18.      procedure WndProc(var Message: TMessage); override;
  19.   end;
  20.  
  21. var
  22.   Form1: TForm1;
  23.  
  24. implementation
  25.  
  26. {$R *.dfm}
  27. procedure TForm1.WndProc(var Message: TMessage);
  28.  var
  29.    p: TENLink;
  30.    strURL: string;
  31.  begin
  32.    if (Message.Msg = WM_NOTIFY) then
  33.    begin
  34.      if (PNMHDR(Message.lParam).code = EN_LINK) then
  35.      begin
  36.        p := TENLink(Pointer(TWMNotify(Message).NMHdr)^);
  37.        if (p.Msg = WM_LBUTTONDOWN) then
  38.        begin
  39.          SendMessage(RichEdit1.Handle, EM_EXSETSEL, 0, Longint(@(p.chrg)));
  40.          strURL := RichEdit1.SelText;
  41.          ShellExecute(Handle, 'open', PChar(strURL), 0, 0, SW_SHOWNORMAL);
  42.        end
  43.      end
  44.    end;
  45.  
  46.    inherited;
  47.  end;
  48. procedure TForm1.FormCreate(Sender: TObject);
  49. var
  50.    mask: Word;
  51.  begin
  52.    mask := SendMessage(Handle, EM_GETEVENTMASK, 0, 0);
  53.    SendMessage(RichEdit1.Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK);
  54.    SendMessage(RichEdit1.Handle, EM_AUTOURLDETECT, Integer(True), 0);
  55.    RichEdit1.Lines.Add('SwissDelphiCenter.com: '#13#10 +
  56.      ' Site is located at www.SwissDelphiCenter.com');
  57. end;
  58.  
  59. end.
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment