title: How to implement the mouse click for URLs at rich edit control
body: <p>I added a read-only rich edit 2.0 control to my dialog (code is using C windows API, the dialog is created by using function <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms645452%28v=vs.85%29.aspx" rel="nofollow">DialogBox</a>)</p>
  
  <p>At the dialog call back, at the WM_INITDIALOG, I add the following code to enable url detection and also enable the event ENM_LINK is sent to the parent dialog instead of the rich edit control itself:</p>
  
  <pre><code>LRESULT mask = SendMessage(hWndText, EM_GETEVENTMASK, 0, 0); //hWndText is rich edit control
  SendMessage(hWndText, EM_SETEVENTMASK, 0, mask | ENM_LINK);
  ::SendMessage(hWndText, EM_AUTOURLDETECT, TRUE, NULL);  
  </code></pre>
  
  <p>I had a little trouble to enable the url detection when dialog is initially launched (which seems a known issue or behavior since rich edit control would only enable url detection of modified text). However I worked around this issue by setting the dialog text again on every WM_PAINT event. </p>
  
  <p>The code is generally working. I also implemented the following code to launch the URL at the browser when mouse is hovering over the url:</p>
  
  <pre><code>case WM_NOTIFY:
      plink = (ENLINK *) lParam;
      switch(LOWORD(wParam))
      {   
          case IDC_DISPLAY_TEXT_2: //this is ID for my rich edit control
              szURL =m_strDisplay.Mid(plink-&gt;chrg.cpMin, plink-&gt;chrg.cpMax - plink-&gt;chrg.cpMin);          
              LaunchURL(szURL); //function to launch the url with default browser
              break;
          default:
              break;
      }
  </code></pre>
  
  <p>It seems that I would get WM_NOTIFY event every time when I hovered the mouse over the url. However when I clicked on it, I always get same event as the mouse hover over.</p>
  
  <p>Based on the structure of <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787897%28v=vs.85%29.aspx" rel="nofollow">ENLINK</a>, I should get more detailed NM event at the NMHDR structure, however the value plink->nmhdr.code is always 1803 which is not even NM_HOVER (its defined value is (NM_FIRST-13)  and NM_FIRST is (0U-  0U), so NM_HOVER value is 4294967283 on my 64 bit machine). I know that I am missing something here. Could someone shed some lights here? How can I get the mouse click event for the rich edit control?</p>