
![]() |
| //这个是我们自定义的InitRichEditURLDetection过程 //它是最关键的一步 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; //这是FormCreate事件,它加入了我们自定义的过程 //使得程序一运行就出现我们想要实现的效果 procedure TForm1.FormCreate(Sender: TObject); var s: string; begin InitRichEditURLDetection(RichEdit1); s:='http://www.yesky.com' + #13#10 + 'mailto:software@chinabyte.com'; RichEdit1.Text := s; s:= 'http://www.yesky.com' + #13#10 + 'mailto:software@chinabyte.com'; RichEdit2.Text := s end; |
| //Form的WndProc过程 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; |
![]() |
| 关于我们 | 联系我们 | 广告服务 | 工作机会 | 版权声明 | 欢迎投稿 | 网站地图 |
| Copyright © 2000-2008 , www.21tx.com , All Rights Reserved . |
| © 晨新科技 版权所有 Created by TXSite.net |