Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ComCtrls, ShellApi, RichEdit, StdCtrls;
- type
- TForm1 = class(TForm)
- RichEdit1: TRichEdit;
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- protected
- procedure WndProc(var Message: TMessage); override;
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.WndProc(var Message: TMessage);
- var
- p: TENLink;
- strURL: 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
- SendMessage(RichEdit1.Handle, EM_EXSETSEL, 0, Longint(@(p.chrg)));
- strURL := RichEdit1.SelText;
- ShellExecute(Handle, 'open', PChar(strURL), 0, 0, SW_SHOWNORMAL);
- end
- end
- end;
- inherited;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- var
- mask: Word;
- begin
- mask := SendMessage(Handle, EM_GETEVENTMASK, 0, 0);
- SendMessage(RichEdit1.Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK);
- SendMessage(RichEdit1.Handle, EM_AUTOURLDETECT, Integer(True), 0);
- RichEdit1.Lines.Add('SwissDelphiCenter.com: '#13#10 +
- ' Site is located at www.SwissDelphiCenter.com');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment