added URL detection and provided hotlinks in the ICS client
authorEric Mullins <emwine@earthlink.net>
Sat, 10 Oct 2009 08:03:45 +0000 (02:03 -0600)
committerEric Mullins <emwine@earthlink.net>
Sat, 10 Oct 2009 08:03:45 +0000 (02:03 -0600)
winboard/winboard.c

index 0fa4807..99f95ba 100644 (file)
@@ -8245,6 +8245,23 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   MINMAXINFO *mmi;\r
 \r
   switch (message) {\r
+  case WM_NOTIFY:\r
+    if (((NMHDR*)lParam)->code == EN_LINK)\r
+    {\r
+      ENLINK *pLink = (ENLINK*)lParam;\r
+      if (pLink->msg == WM_LBUTTONUP)\r
+      {\r
+          TEXTRANGE tr;\r
+\r
+          tr.chrg = pLink->chrg;\r
+          tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin);\r
+          hText = GetDlgItem(hDlg, OPT_ConsoleText);\r
+          SendMessage(hText, EM_GETTEXTRANGE, 0, (LPARAM)&tr);\r
+          ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW);\r
+          free(tr.lpstrText);\r
+      }\r
+    }\r
+    break;\r
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     hwndConsole = hDlg;\r
     hText = GetDlgItem(hDlg, OPT_ConsoleText);\r
@@ -8365,10 +8382,18 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 VOID\r
 ConsoleCreate()\r
 {\r
-  HWND hCons;\r
+  HWND hCons, hText;\r
+  WORD wMask;\r
   if (hwndConsole) return;\r
   hCons = CreateDialog(hInst, szConsoleName, 0, NULL);\r
   SendMessage(hCons, WM_INITDIALOG, 0, 0);\r
+\r
+\r
+  // make the text item in the console do URL links\r
+  hText = GetDlgItem(hCons, OPT_ConsoleText);\r
+  wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L);\r
+  SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK);\r
+  SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L);\r
 }\r
 \r
 \r