How to autodetect urls in RichEdit 2.0?

后端 未结 3 668
一个人的身影
一个人的身影 2021-01-28 21:26

When we have a RichEdit control and send it an EM_AUTOURLDETECT message with WPARAM set to TRUE, it nicely hightlights the detected URLs and sends the EN_LINK

3条回答
  •  佛祖请我去吃肉
    2021-01-28 22:12

    I just knocked up a basic WTL dialog based app containing a riched20 control and the following works fine:

    CRichEditCtrl richedit = GetDlgItem(IDC_RICHEDIT);
    richedit.SetAutoURLDetect(TRUE);
    richedit.SetWindowText(_T("http://www.stackoverflow.com"));
    

    I have some old MFC code that does something similar, albeit with ES_STREAM, and it works OK too.

    FWIW the WTL CRichEditCtrl wrapper is pretty thin. SetAutoURLDetect simply calls SendMessage passing it EM_AUTOURLDETECT.

    I am compiling with _RICHEDIT_VER set to 0x0200 FWIW.

提交回复
热议问题